PHP file upload - space character in folder name


I am new to the forum and hope this community can assist me. I am trying to upload files to a specified path, but if a folder name has a space in its name, the upload fails. Here is my code:

$storage_path = $_POST[“storage_path”];

$filename = $_FILES[‘Filedata’][‘name’];
$filetmpname = $_FILES[‘Filedata’][‘tmp_name’];

$filename_no_spaces = str_replace(" ", “_”, $filename);
move_uploaded_file($filetmpname, $storage_path . $filename_no_spaces);


So you see, my storage path is passed via POST. ex: c:\folderone\folder two\

The move_uploaded_file function fails when there is a space in the folder name. Hope you can help.


omg, nevermind this post. I realized that I have to wrap the path in quotes to account for the spaces.


Sponsor our Newsletter | Privacy Policy | Terms of Service