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

Creating a page from which people can download a file

New Here ,
Nov 02, 2006 Nov 02, 2006

Copy link to clipboard

Copied

My client wants people to be able to download sermons from the church web site. They are delivered as .mp4 files so they can use them in IPods.

I have tried simply listing them (link is in the database) and telling them to right click on them. That works superbly in Firefox 1.5 and 2.0, but I get errors in Opera (latest version) and IE 7.

I have tried using CFCONTENT (code below) and it works great in Firefox 1.5, but not in Firefox 2.0, IE 7 or Opera.

Here's the code. Any help would be appreciated.


<cfoutput query="GetSermon">
<cfquery name="GetSermon" datasource="db">
Select * from sermons
WHERE sermon_id=#form.sermon_id#
</cfquery>

<cfset sermonfile =#sermon_link#>
<cfcontent type="application/x-unknown">
<cfheader name="Content-Disposition" value="attachment;filename=#sermonfile#">
<cfheader name="Content-Description" value="This is a sound file.">
<cflocation url=" http://www.trinitypres.us/tpc/sermons/#sermonfile#">
</cfoutput>

TOPICS
Advanced techniques

Views

349

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 02, 2006 Nov 02, 2006

Copy link to clipboard

Copied

Take a look at the cgi variables. One of them might give you enough browser info to use if/else or case/switch logic with.

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
New Here ,
Nov 03, 2006 Nov 03, 2006

Copy link to clipboard

Copied

LATEST
Another person suggested this:

download and .mp3 instead of an .mp4. If you use an .mp3, use the " audio/mpeg3" as the <CFContent> type

Further, take the <CFLocation> out.

End the code with a <cfabort> tag.

Thus the code looks like this:

<cfoutput query="GetSermon">


<cfset sermonfile =#sermon_link#>
<cfcontent type="application/audio/mpeg3">
<cfheader name="Content-Disposition" value="attachment;filename=#sermonfile#">
<cfheader name="Content-Description" value="This is a sound file.">
<!--- <cflocation url=" http://www.trinitypres.us/tpc/tpc/sermons/#sermonfile#"> --->
<cfabort>
</cfoutput>

It works with IE7, Firefox 2.0 and Opera 9.

Thanks for the assist -- not sure which CGI variables I would have checked.

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