[thelist] Downloading Files in CF

Joe Crawford jcrawford at avencom.com
Tue Jun 12 12:48:03 CDT 2001


Chris Johnston wrote:
> I am trying to create an application in ColdFusion that allows user to
> upload and download files. I have the upload part working fine, however
> I can't get the download part to work quite as well.
> 
> Here are the requirements for the files;
> 
> 1. They are currently being uploaded to a directory that is away from
> the website root directory
> (eventually, they will be uploaded to a separate computer.)
> 2. The users can upload any type of file they wish.
> 3. The directory/file server cannot be an ftp server for security
> reasons.
> 
> The problem comes when they try to download the files. I have tried to
> use cfcontent but without a proper mime type, it simply tries to save
> every file as foo.htm (the name of the page calling the file). I have
> tried to use an ftp server but it displays the loginid and the password
> at the bottom of the browser.
> 
> Does anyone have any experience with this in ColdFusion? Is this even
> possible to do, or do the files have to reside below the website root
> directory or on an ftp server?

We use:

<cfcontent type="application/x-unknown">
<cfheader
	name="Content-Disposition"
	value="attachment;filename=#attributes.FileName#">
<cfheader
	name="Content-Description"
	value="This is a tab-delimited file.">
<cflocation url="#request.CSVRoot#/#attributes.FileName#">

Where #attributes.FileName# is what you want the name of the file to be.

And the #request.CSVRoot# is the path to the original.

HTH!
	Joe <http://artlung.com/>
-- 
...................  Joe Crawford \\ Web Design & Development
.....  mailto:jcrawford at avencom.com \\ http://www.avencom.com
.... San Diego \\ CA \\ USA \\ AVENCOM: Set Your Sites Higher




More information about the thelist mailing list