Note to self: Using CFCONTENT to force file download instead of display
Categories: Coldfusion
Sometimes I see something useful and I know I'll never remember it, so I'm gonna post it here on my blog.
If you want to force download a document instead of displaying it inline (for example, a jpg image, or a word document (which IE will display inline!)), use the following code in a CFM file:
<cfheader name="Content-disposition" value="attachment;filename=test.jpg">
<cfcontent type="image/jpeg" file="D:\htdocs\filecabinet\test.jpg">
<cfcontent type="image/jpeg" file="D:\htdocs\filecabinet\test.jpg">
Poof! Instant download dialog!
Posted by rickroot at 10:40 AM | Link | 3 comments
Subscription Options
You are not logged in, so your subscription status for this entry is unknown. You can login or register here.
Re: Note to self: Using CFCONTENT to force file download instead of display
I was wondering where you got the anti spam key or if you have just created your own system. I am looking to implement the same idea into some of my forms to stop the spam bots. Any information you could share with me would be aprreciated.
Posted by Steve Reich on July 9, 2006 at 8:48 PM
Re: Note to self: Using CFCONTENT to force file download instead of display
It'd built into BlogCFM - you can download the latest version and yank out the associated code with the anti-spam key.
Posted by rickroot on July 10, 2006 at 5:23 AM
Re: Note to self: Using CFCONTENT to force file download instead of display
I read somewhere that you can also do this, though I haven't tried it:
cfcontent type="application/unknown"
cfheader name="Content-Disposition" value="inline; filename=#filename#"
cfcontent type="application/unknown"
cfheader name="Content-Disposition" value="inline; filename=#filename#"
Posted by Michael Muller on August 29, 2006 at 7:17 PM