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) --->
That's it.. you're done! :)
This is a brief demonstration on how to use Fusebox 2.0 Methodology.
This tutorial will demonstrate how to create a query from two different queries based from two separate datasources. This is the easiest way to combine your data.
This tutorial will show you how to load your images from an actual .cfm page. Therefore, allowing you to prevent people from using your content on their web sites.
This new tutorial series will show you how to create user interfaces with ColdFusion MX 8!
This tutorial will show you how to efficiently re-use code and in addition how to create a random list of colors that you can use with cfchart colorlist.
Have you ever wanted to let your annonymous (non logged in / members) users know what items they have not yet read in your blog or discussion board / forum? This tutorial shows you a real easy and quick way to do just that... take a look now!