I tend to do a lot of document serving in my daily routines, by this I mean serving documents from the server to the visitor (end-user) in formats other then HTML..
Such as PDF, MS Word, MS Excel, etc..
Now, the easiest and fastest way to achieve this is to use CFCONTENT.
You simply use CFCONTENT to serve the file (using an MS WORD AS AN EXAMPLE) as follows:
<cfcontent type="application/msword" file="#ExpandPath(".")#\Tutorial_#URL.TutorialID#.doc" deletefile="yes">
Now the only problem is that doing this will make the download be the name of your ColdFusion template, and not that of the file you want named (such as: "tutorial_1.doc".
So how do we get around this? Using CFHEADER as follows:
<cfheader name="content-disposition" value="attachment;filename=Tutorial_#URL.TutorialID#.doc">
This will ensure that the downloaded file will be called what YOU want it to be called! :)
Here's how to use it:
<!--- all your processing here to create the file you want to load (or load one with CFFILE if it already exists) --->
<!--- Now trick the browser and name the file whatever you want --->
<cfheader name="content-disposition" value="attachment;filename=Tutorial_#URL.TutorialID#.doc">
<!--- now serve the content --->
<cfcontent type="application/msword" file="#ExpandPath(".")#\Tutorial_#URL.TutorialID#.doc" deletefile="yes">
That's it.. you're done! :)
EasyCFM.Com introduces at least three new tutorials each week, written by the webmaster (Pablo Varando) and also from individual people who post their own tutorials for visitors to learn from. For more information please visit: http://www.easycfm.com [EasyCFM is Hosted by Colony One On-Line - http://www.colony1.net]
Publish A Comment
| Popular WPN Business Resources |
-

The Rise of Horizontal Content Sites
Over the last year, the search industry has seen a large rise in... -

Reaching Your Audience Through Online Video
Internet video is continuing to grow by leaps and bounds. -

Yahoo Reveals SEM of Re-Brand
Near the end of September, Yahoo began a new branding campaign in an...
iEntry 10th Anniversary
RSS
Newsletter
Advertising





















Correct Content (document) Serving!
how can you upload more than one file at a time using your example?
Thanks