Skip to main content
Inspiring
November 22, 2006
Question

Force Download

  • November 22, 2006
  • 4 replies
  • 796 views
Why won't this work? Its from the Live Docs but using a MP3 instead of using
an Excel spreadsheet from the example.

<cfheader name="Content-Disposition" value="inline;
filename=advocate-show3-48kbit.mp3">
<cfcontent type="audio/mpeg" file="c:\temp\advocate-show3-48kbit.mp3">

I want to force a download of the MP3. Any better / working examples of
this?


This topic has been closed for replies.

4 replies

Participating Frequently
November 22, 2006
Is this in IE? What does it do in other browsers? What do the actual response headers look like?
November 24, 2006
I just went trough something similar,.. I found IE and mozilla behaved differently depending on ~where~ the header and content tags were placed on the page..

maybe try:
- place the content and header tags first (before any sort of DTDs ) on the page or even by themselves.
- check the docs to be sure you are not using an incompatible tag on the same page ummm cflocation and cfflush i beleive..

here is what worked for me... the content type and filenames were stored in a database.

<cfquery name="update" datasource="#Application.DataSource#">
update files set WasDownloaded = '1' where DID = '#url.DID#'
</cfquery>
<cfquery name="select" datasource="#Application.DataSource#">
select * from files where DID = '#url.DID#'
</cfquery>

<cftry>
<cfheader name="Content-disposition" value="attachment;filename=#select.ServerFileName#">
<cfcontent type="#select.DocType#" file="#select.ServerFilePath##select.ServerFileName#" DeleteFile="No">
<cfcatch type="any">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Error</title>
<link href="/script/styles.css" rel="stylesheet" type="text/css" />
</head>

<body>
<table width="100%" border="0">
<tr>
<th scope="col">An Error Has occurred. </th>
</tr>
<tr>
<td><p align="center"> </p>
<p align="center">An unknown error has occurred.</p>
<p align="center">Please report this to the <a href="mailto=#Appplication.AdminMail#">Administrator</a> </p>
<p align="center" class="tinytext"><a href="" onclick="window.close();">Close Window</a></p>
<p align="center"> </p></td>
</tr>
</table>
</body>
</html>
</cfcatch>
</cftry>
Inspiring
November 22, 2006
It shows a watermark of Quicktime in the background with a question mark.

"Adam Cameron" <adam_junk@hotmail.com> wrote in message
news:swhk44h0nvxw.1ej0obukthrlt.dlg@40tude.net...
>> doesnt work
>
> Can you elaborate on that? Obviously it doesn't force the D/L, but what
> DOES it do, instead?
>
> --
> Adam


Participating Frequently
November 22, 2006
If you change the content type to "unknown", it will force the browser to open a save dialog rather than attempting to deal with it based on its advertised content type.
Inspiring
November 22, 2006
> doesnt work

Can you elaborate on that? Obviously it doesn't force the D/L, but what
DOES it do, instead?

--
Adam
Inspiring
November 22, 2006
Ok, now I found this:

<cfheader name="Content-disposition"
value="attachment;filename=advocate-show3-48kbit.mp3">
<cfcontent type="audio/mpg"
file="E:\www\news\media\audio\advocate-show3-48kbit.mp3">

Still doesnt work... hmmm.. What am I missing here?