Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Filename: Replace spaces with underscores

Engaged ,
Nov 03, 2008 Nov 03, 2008
Greetings,

I have searched the forum and online and have not found an answer.
So posting here for assistance.

What is the proper syntax for replacing spaces in file names with under
scores prior to cffile upload? -or- what is the best method to accomplish
this process?

Example:
document name.doc >> document_name.doc

Thanks

Leonard
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 03, 2008 Nov 03, 2008
LATEST
you can't change the filename before the file has been uploaded to your
server.

upload a file using cffile.
#cffile.serverfile# variable will contain the name with which the file
has been saved on your server.
check if the name contains any spaces using find() cf function.
if it does, use cffile action="copy" to copy the file as a file with no
spaces in the name (use replace() cf function to replace spaces with
whatever you want).
[you may want to make sure prior to copying the file that there is not
already a file with same name (with no spaces) in that folder, otherwise
the copy action will overwrite existing file]
delete original file.

details of all the functions are in the CFML Reference. if you do not
have one - download free from adobe.com

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources