Just a minor note that I thought I would post up here (since I didn't know this before and I had to test it for myself). When it comes to web development, pretty much all of my file names are purely alpha-numeric with underscores for spaces. As such, I have never come up against a problem in ColdFusion where I needed to used space-containing file names in conjunction with the CFHeader content-disposition value. In fact, I've never even thought about it.
In my post on using additional path information to alter the browser's Save-As behavior, Elliott Sprehn pointed out to me that in order to handle spaces in file names, you have to quote the file names. And, not only do you have to quote it, you have to use double quotes, NOT single quotes - single quotes do nothing to help you out and the first single quote actually shows up in the file name (before the name gets truncated).
Here is my test ColdFusion template. All it does is try to server up a file as an attachment:
<!--- Kill extra output. --->
value="attachment; filename=""This Is A Test.txt"""
variable="#ToBinary( ToBase64( 'Test Data' ))#"
Notice that in order to get the quotes to work, you have to double them up (otherwise ColdFusion will think you are ending the string). You could also use single quotes for the value attribute, but that's not my style.
Running the above template directly, I am correctly prompted by FireFox to download the file with the proper name:
I probably won't switch over to using file names with spaces, but in something like a document management system, I can see where knowing this would be super helpful.
Want to use code from this post? Check out the license.