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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using the Replace Function to replace " and ,

Status
Not open for further replies.

jeepxo

Programmer
Oct 1, 2002
228
CA
I'm using the <cffile> tag to upload files to a server. I'd like to replace some characters if they are used in the file name so that I can use the file name in a URL later on.

My understanding of the Replace function is that it takes a string for the characters you want replaced, and a string for the characters to replace them with, and that it is comma delimitted.

So if upload the file then rename it without the characters that I don't want I think that would work. My problem is removing some special characters like &quot;, ', and comma's

for example if a file was named

my Bad'name&quot;,file.doc

how would I create a comma delimitted string to represent the space, the single quote the comma and the double quote?

doing a <CFSET myBadChars =&quot; ,,,',&quot;&quot;> obviously isn't going to work.

&quot;Every day is like a precious gift, you have to make it count&quot; James Birrell 1993-2001
 
So, what I think you're saying is that you'd like to take the file name from the uploaded file and remove any comma, apostrophe, and quote characters.

Try this:
Code:
<cffile 
   action=&quot;RENAME&quot;
   source=&quot;#CFFILE.ServerFile#&quot;
   destination=&quot;#REReplace(CFFILE.ServerFile,&quot;[,&quot;&quot;']&quot;,&quot;&quot;,&quot;ALL&quot;)#&quot;>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top