I came across an issue with differences in the way firefox and ie7 handle cfheader attachments when wanting to download a file using ColdFusion. The problem is firefox will cut off the downloaded file at the first space in the filename. And, IE7 and above will replace spaces with underscores. To alleviate the problem, you must do the following:
cfif CGI.HTTP_USER_AGENT contains("MSIE")
cfset variables.theFilename = URLEncodedFormat(#filename#)
cfelse
cfset variables.theFilename = #filename#
cfif
CFHEADER NAME="Content-Disposition" VALUE="Filename=""#filename#
""">
Take note of the urlEncodedFormat which runs if you are using IE. IE will know to replace %20 with spaces in the filename upon download, and the double "" around the variable in the cfheader tag will let Firefox use the entire filename upon saving.
No comments:
Post a Comment