tags:

views:

17

answers:

1

hey guys, i'm using ftp_put to uplaod files to my ftp server. if i select a file with like "Some Zip.jpg" i want it automatically to rename to "Some_Zip.jpg" with underscores instead of spaces.

$name=$_FILES['userfile']['name']; 

how can i replace all spaces in $name with underscores. Is there anything else i should be aware of when i upload files to my ftp? i mean slashes are generally not working for filenames, so they can't be there in the first place. everything else should be fine i think.

regards matt

+3  A: 

You should bind the filename to a string and use str_replace to get a new name for the file

$filename = "This is a document.doc"
$newfile = str_replace(' ', '_', $filename)
websch01ar