Click to See Complete Forum and Search --> : Download links for files on the server - help


Frost
08-12-2010, 07:32 AM
I'm pretty much at the beginner level of ColdFusion. I'm using the latest version of Railo. I have a page where I list files in a directory on the server. No problem there.

When I link them, I'm not getting a prompt to download, it tries to go to a page which ends up not being found. I was told I need to use a combination of cfheader and cfcontent but I can't get it to work. The closest I've been is when I click a link, the page tries to load the file (mp3) in the browser so I just see a bunch of garbled text.

I've looked at adobe livedocs and saw something at bennadel. Just can't make much sense of it.

Any suggestions?

WolfShade
12-22-2010, 08:31 AM
I know this is months old and you've probably given up on getting an answer, but CFCONTENT and CFHEADER is the way to go. Just make sure you've got the right MIME type specified.


<cfheader name="content-disposition" value="attachment;filename=[filename.ext goes here]">
<cfcontent type="[mimetype value]" variable="[binary data]">


I created a CFC that will return a mimetype based upon the file extension. I'll attach it for anyone who would like it.

^_^