• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Force Download

LEGEND ,
Nov 22, 2006 Nov 22, 2006

Copy link to clipboard

Copied

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?


TOPICS
Advanced techniques

Views

712

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 22, 2006 Nov 22, 2006

Copy link to clipboard

Copied

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?


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 22, 2006 Nov 22, 2006

Copy link to clipboard

Copied

> doesnt work

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

--
Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 22, 2006 Nov 22, 2006

Copy link to clipboard

Copied

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


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Nov 22, 2006 Nov 22, 2006

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 22, 2006 Nov 22, 2006

Copy link to clipboard

Copied

Tried that and got the same result.


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Nov 22, 2006 Nov 22, 2006

Copy link to clipboard

Copied

Is this in IE? What does it do in other browsers? What do the actual response headers look like?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Nov 24, 2006 Nov 24, 2006

Copy link to clipboard

Copied

LATEST
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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation