Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cffile

Status
Not open for further replies.

danarashad

Programmer
Nov 2, 2006
115
US
Is there away to remove special characters from a file thats being uploaded.
I can do this to strip out invalid characters, to insert into the database.
#REReplace(form.image1, "[^0-9a-zA-Z_]", "", "ALL")#
But I am having trouble stripping the invalid characters out of the upload.
 
From what I can tell, to remove the special characters you must first upload the file. This will give you the cffile.serverFile variable containing the name of the file you uploaded. I'm not sure if you can change the value of the variable. You might be able to. But what you can definitely do is set a temporary variable with the value from the cffile.serverFile variable.

Example:
<cfset tempFileName = cffile.serverFile>

Use your code to remove the characters you don't want. Once the temporary variable has the file name in the format you want, use the cffile action="rename" attribute to rename the file name.


Example:
<cffile action="rename" destination="#variables.tempFileName#" source="#cffile.serverFile#">
 
Why not just rename the file after it uploads?

Not tested:
Code:
<cffile action="upload" filefield="filefiled" destination="#myUploadDir#" nameConflict = "MakeUnique">
<cffile action="rename" source="#myUploadDir#/#cffile.serverFile#" destination="#myUploadDir#/newname.#clientFileExt#" nameconflict="overwrite">

_____________________________
Just Imagine.
 
Yeah thats what I am doing. I didn't know if there was a way to do it all at once.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top