Search

Thursday, December 28, 2006

IE and Firefox Friendly Filenames from ColdFusion

When generating files from ColdFusion (such as Excel) it is important to make the filename friendly to both Internet Explorer and Firefox. On top of that, when using Windows, the filename should not contain any special characters (as considered by the OS). Here is a regular expression that will remove replace special characters and multiple consecutive spaces with a dot (".").
<cfset fileName = fileName.replaceall('["\/\\\[\]:;\|=,\*\?]|\s+', ".") />
// //]]>