Problems with CFCONTENT and Firefox downloading filenames with spaces...

Posted by Dan on Dec 2, 2005 @ 2:01 PM

If you use <cfcontent> and <cfheader> tags to push files to the browser, then you may have come across this problem. You're pushing a file that contains spaces in the name. In Internet Explorer, the file gets downloaded with the correct filename, but in Firefox the filename only contains the first word in the filename.

I've ran into this problem a little while ago and instead of spending a bunch of time trying to figure it out, I just replaced the spaces with underscores. However, today Jeff Smallwood posted that he was having the same problem on a mailing list. Charlie Arehart suggested using quotes to surround the filename in the value attribute of the <cfheader> tag. After some testing, Jeff found that this does in fact fix the problem. Here's an example:

<cfheader
	name="Content-Disposition"
	value="attachment; filename=""this file has spaces.txt"""
	/>

I've now gone back and fixed the code so that it will correctly serve files with spaces in the name.

Categories: HTML/ColdFusion

4 Comments


Comments for this entry have been disabled.