filterFilename(filename)
Last updated January 19, 2006
Version: 1 | Requires: CF6 | Library: UtilityLib
Description:
This function will remove any reserved characters from a filename string and replace any spaces with underscores.
Return Values:
Returns a string.
Example:
<cfset newfilename = filterFilename(filename) />
<cfoutput>
#newfilename#
</cfoutput>
Parameters:
Name | Description | Required |
---|---|---|
filename | Filename. | Yes |
Full UDF Source:
<!---
This function will remove any reserved characters from a filename string and replace any spaces with underscores.
@param filename Filename. (Required)
@return Returns a string.
@author Jason Sheedy (jason@jmpj.net)
@version 1, January 19, 2006
--->
<cffunction name="filterFilename" access="public" returntype="string" output="false" hint="I remove any special characters from a filename and replace any spaces with underscores.">
<cfargument name="filename" type="string" required="true" />
<cfset var filenameRE = "[" & "'" & '"' & "##" & "/\\%&`@~!,:;=<>\+\*\?\[\]\^\$\(\)\{\}\|]" />
<cfset var newfilename = reReplace(arguments.filename,filenameRE,"","all") />
<cfset newfilename = replace(newfilename," ","_","all") />
<cfreturn newfilename />
</cffunction>
Search CFLib.org
Latest Additions
Raymond Camden added
QueryDeleteRows
November 04, 2017
Leigh added
nullPad
May 11, 2016
Raymond Camden added
stripHTML
May 10, 2016
Kevin Cotton added
date2ExcelDate
May 05, 2016
Raymond Camden added
CapFirst
April 25, 2016