Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move
Warning occurred when uploading files today: move_uploaded_file() [function.move-uploaded-file]: Unable to move
if(!empty($_FILES[fileup][name])){
$fileinfo=$_FILES[fileup];
$type=strstr($fileinfo['name'],".");
If($type!=".jpg"){
echo "The format of the file you uploaded is incorrect!";
}else{
If($fileinfo['size']<209715 && $fileinfo['size']>0){
$path="10/".$_FILES["fileup"]["name"];
move_uploaded_file($fileinfo['tmp_name'],$path);
If(is_dir("10/")){
$dir=scandir("10/");
foreach($dir as $value){
echo $value."
";
}
}else{
echo "Directory path error!";
}
}else{
echo 'The file size does not meet the requirements! ';
}
}
}
?>
Running result:
Warning: move_uploaded_file(10/02.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in E:appsTutorialerv-win32-2.5.10AppServwww10index_7.php on line 26
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:WINDOWStempphp1A.tmp' to '10/02.jpg' in E:appserv-win32-2.5.10AppServwww10index_7.php on line 26
Directory path error!
The solution is to change the relative path to absolute
$_SERVER[DOCUMENT_ROOT] . '/10/' . $_FILES['fileup']['name'];
Solution
Will
move_uploaded_file($_FILES["file"]["tmp_name"],"upload/" . $_FILES["file"]["name"])
Change to
move_uploaded_file($_FILES["file"]["tmp_name"],"d:/" . $_FILES["file"]["name"])
Method 2
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move
An error like this occurs when uploading. The reason is whether the directory permissions are writable.
Generally, setting 777 can solve the problem. ,
Modify permissions command:
chmod 777 filename
chmod 777 dirname
sudo chmod 777 filename/dirname
chown wgr:admin dirname -R
Note: -R batch execution