Data output tags. You can specify this tag's attributes in an attributeCollection attribute whose value is a structure. Specify the structure name in the attributeCollection attribute and use the tag's attribute names as structure keys. Now, ColdFusion attempts to get the content type from the file.
|Published (Last):||26 January 2013|
|PDF File Size:||14.23 Mb|
|ePub File Size:||2.42 Mb|
|Price:||Free* [*Free Regsitration Required]|
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. 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. When I look at the http headers that get sent back with the file request Thanks god for FireBug!!
Therefore, I assume it is the browser that requires them. It's the browser. Did you know that IE7 puts underscores in the name of the file when you use the double quote method?
If you take out the double quotes, it works perfectly for IE7. Any ideas other than recognizing the browser and placing separate code for each? I'm thinking I have no choice at this point. Thanks for this, never thought of putting double quotes - was putting single quotes and of course they didn't work.
Always had this problem and I was stripping the spaces to the consternation of the users who wanted to preserve the file name. Nice, that should work. By using the chr method, you don't have to escape the quotes by doubling them up.
Good thinking. Here is my question, where can I find everything that cfheader can do for me? I've found bits and pieces but there must be more. Do I have to look for just headers or what? My googling fingers are wearing out. There's not inherent limit to what you can send in headers. I think the only technical limit is that headers can't have line-breaks otherwise the client interprets the post-line-break content as a new header value or the body Is there something you were looking for in particular?
Or were you just getting ideas for what was capable? Ben, Primarily I was looking for what is available. Another one of those times when I was looking at one thing and thought "what else? I finally found a place that showed a lot of what is routinely done with headers such as size etc.
Not sure how much of it is really useful except the caching stuff. One of the most important headers that you can set it he content-type header, which can be set implicitly using the CFContent tag.
Other than that, I really only use headers an as-needed basis. Or when the download dialog box is closed? I have js code that changes the submit button to disabled and it says 'Please Wait' , so that the user can't click and submit it more than once. Is there a way to trigger code enabling and changing the submit button text back?
Here is my test ColdFusion template. Woot woot — you rock the party that rocks the body! Peter, When I look at the http headers that get sent back with the file request Thanks god for FireBug!! You're welcome Ben! Peter It's the browser. JC, Sorry, no ideas. I haven't even upgraded to IE7 yet, so I wouldn't even know how to test. Another few hours saved because of your excellent blog - thanks! Mac Oct 1, at AM 1 Comments.
Thanks a ton Ben!!! Mark, Nice, that should work. Ram Mar 16, at PM 1 Comments. I am try to use this code with in a cfdiv submit and it is not working. Can you please advice. Nelgraine Jun 18, at AM 4 Comments. Nelgraine Jul 15, at AM 4 Comments. Nelgraine Jul 16, at AM 4 Comments.
Nelgraine, Interesting - you are url-encoding the file name. I have never tried that before. Don Oct 4, at PM 57 Comments. Don, There's not inherent limit to what you can send in headers. So, you can send any application-specific headers that you like. Don Oct 5, at AM 57 Comments.
Don, One of the most important headers that you can set it he content-type header, which can be set implicitly using the CFContent tag. Angie Mar 18, at PM 1 Comments. Oh my chickens, this post is old! Hit me up on Twitter if you want to discuss it further.
Using CFHeader With File Names Containing Spaces (Thanks Elliott Sprehn!)
Subscribe to RSS