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

Strange problem

Status
Not open for further replies.

FredrikN

Programmer
Jan 5, 2001
60
SE
Hi.
I'm using a php upload script and it works fine(99%) anyway.

The problem is that I can upload files with spaces like
aa bb.jpg or something.


This is the code I'm using, maybee anyone knows what the problem is ?


snip ---

if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) {
copy($HTTP_POST_FILES['userfile']['tmp_name'], "/home/user/tmp/file");
system ("mv /home/user/tmp/file /home/user/public_html/$tmpname");

end of snip ---

This will put the uploaded file in public_html with the real name of the file

It works fine if the file name is aabb.jpg but not with aa bb.jpg

Thanks.
 
let me guess, it will either name the file orignally called "a bb.jpg" to "aa"?
what you would need to do, is temporialy change the " " charactor to something else, ie change it to ##space## then then do a s&r on ##space## to convert it back to a " ". I had this problem with a similar perl script, and after doing the s&r routine to replace all the spaces with ##space## handle them, then re-convert them back, it worked perfectly.
(this is also great for handeling < > @ [ ] % $ * = + - / and &quot; chars)
Cheers. /Sib
programmer in the making
icq: 44167565
e-mail: siberdude@ntlworld.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top