|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-10-05 17:41 UTC] steele at agora-net dot com
Description:
------------
The move_uploaded_file() function fails when given a path that contains spaces or apostrophes. Have tried manually escaping them as well, with the same result. The copy() function does not fail in this respect. Tested on three separate machines, and had members in the IRC channel test as well.
Reproduce code:
---------------
$target_path = "/path/to/share/ftp/foo blah/bc.png";
if(move_uploaded_file($_FILES[$fileName]['tmp_name'],$target_path)){
echo basename( $_FILES[$fileName]['name']) . " has been successfully uploaded.\n";
}
else{
echo "Upload error!";
}
Expected result:
----------------
bc.png has been successfully uploaded.
Actual result:
--------------
Warning: move_uploaded_file(/path/to/share/ftp/foo blah/bc.png) [function.move-uploaded-file]: failed to open stream: No such file or directory in /path/to/includes/doUpload.php on line 54
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpu6A5ia' to '/path/to/share/ftp/foo blah/bc.png' in /path/to/includes/doUpload.php on line 54
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 03:00:01 2025 UTC |
I'm well aware of why it wouldn't work if the directory did not exist. It does, and has been chmod'ed to 777. Here is the reproduce code you requested: <?php $target_path = "/path/to/share/ftp/foo blah/bc.png"; $tmp = "/tmp/phpu6A5ia"; if(move_uploaded_file($tmp,$target_path)){ echo "$tmp . " has been successfully uploaded.\n"; } else{ echo "Upload error!"; } ?>