Rumah > pembangunan bahagian belakang > tutorial php > Warning: move_uploaded_file() [function.move-uploaded-file]:_PHP教程

Warning: move_uploaded_file() [function.move-uploaded-file]:_PHP教程

WBOY
Lepaskan: 2016-07-13 10:54:52
asal
1018 orang telah melayarinya

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move

今天文件上传出现Warning: 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 "您上传的文件格式不正确!";
        }else{
          if($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 "目录路径出错!";
                 }
          }else{
          echo '文件大小不符合要求!';
          }
        }
}
?>


运行结果:
Warning: move_uploaded_file(10/02.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in E:apps教程erv-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
目录路径出错!


解决办法,把相对路径改绝对

$_SERVER[DOCUMENT_ROOT] . '/10/' . $_FILES['fileup']['name'];

解决办法

move_uploaded_file($_FILES["file"]["tmp_name"],"upload/" . $_FILES["file"]["name"])
改为
move_uploaded_file($_FILES["file"]["tmp_name"],"d:/" . $_FILES["file"]["name"])

方法二

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move
上传的时候出现类似这种报错,原因是目录权限是否为可写的问题。
一般设置777就可以解决。、
修改权限命令:

chmod 777 filename
chmod 777 dirname
sudo chmod 777 filename/dirname
chown wangr:admin dirname -R


注:-R 批量执行

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/632284.htmlTechArticleWarning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 今天文件上传出现Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move form...
Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan