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+', ".") />


  1. I needed this, thanks a lot. I was looking for like a URLencode/decode equivalent. This is money

  2. Glad you like it :-) It has been handy.


// //]]>