Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cfcontent and pdf.

Status
Not open for further replies.

ddfff

MIS
Sep 27, 2002
125
US
I have a page which displays a .pdf file that is stored in sql database.

Let's say that the cfm template that launches the file is called mytemplate.cfm.

Let's say that the .pdf file stored in the db and being displayed is called mypdf.pdf.


The code in mytemplate.cfm is as follows:



<cfcontent type="application/pdf">
<cfoutput>#tostring(myquery.nameofstoredfile)#</cfoutput>

This launches the .pdf in the browser succesfully.

When, in the browser, I click "save a copy", it wants to save the pdf as

mytemplate.pdf
(the cold fusion name)

instead of mypdf.pdf (the actual name of the file). I want to specify which name appears when the users wants to save the .pdf being displayed.

thanks in advance. Help greatly appreciated.
 
Code:
<CFHEADER NAME="Content-Disposition"
VALUE="filename=#your_filename#.pdf">

that might work

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Thank you for the suggestion. It still does not work. Any other suggestions welcome.
 
i would try this as well:
Code:
<cfheader name="Content-Disposition" value="attachment; filename=#FileName#.pdf">
 
Ok. Just about there. Thank you again. Here is what I have:

<cfheader name="Content-Disposition" value="attachment; filename=l1_01.pdf">
<cfcontent type="application/pdf" >
<cfoutput>#toString(test.storedfile)#</cfoutput>

Now the file attempts to save using the filename from the header instead of the name of the calling template. This is what I wanted. The only thing now is that it attempts to save as l1_01[1].pdf. It is appending the [1]. Is there any suggestion on how to prevent this.

Thanks again.
 
it seems to me it would be adding the [1] to the file because a file already exists in the location you are trying to save it. I don't know if it tries to put it in your temp files where it sees you have previously downloaded the file, or if there is a file in your actual download destination with that name.

just shooting from the hip here, i really have no idea why that would happen.
 
I have an idea and I have to say that I have no idea if it will work but it seems worth a shot..

Try adding a path before the filename

Code:
<cfheader name="Content-Disposition" value="attachment; filename=[b]c:\[\b]l1_01.pdf">

If that doesn't work.. Going with what northstar said, try changing the filename in the code to something random like northstardaidea.pdf and see if it geenrates the [1] after it.. If it does, then his idea apparently won't work, if it does, then yay, hopefully he is right.

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
without the & of course

looks like some tgml didn't get processed in your post webmigit =0)
 
Agh..

yeah without the

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top