views:

106

answers:

2

I have a URL that opens a PDF:

<cfoutput>http://myUrl.cfm?params=#many#&lt;cfoutput&gt;

I would like to enable my users to download that PDF instead of having it open in the browser. I've been trying the following, and it isn't working:

<cfoutput>    
<cfcontent type="application/pdf" file="http://myUrl.cfm?params=#many#"/&gt; 
<cfheader name="content-diposition" value="attachment; filename='http://myUrl.cfm?params=#many#'"&gt;
<cflocation url= "http://myUrl.cfm?params=#many#"/&gt;
</cfoutput>

What am I doing wrong?

+10  A: 

<cfheader> before <cfcontent>

you don't need <cflocation>.

http://tutorial217.easycfm.com/

Henry
He also doesn't need the cfoutput block.
Ben Doom
Also 1) The cfcontent "file" value should be an absolute path (ie c:\pathTo\file.pdf". 2) The cfheader "filename" should be a _name_ like "someFile.pdf", not a URL.
Leigh
+1  A: 
<cfheader name="Content-Type" value="unknown">
<cfheader name="Content-Disposition" value="attachment; filename=FileName.jpg">
<cfcontent type="Application/Unknown" file="/http//downloads/FileName.jpg" deletefile="No">
ppshein