程序员人生 网站导航

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

栏目:php教程时间:2014-04-29 06:58:33

今天文件上传出现Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move

  1. "" enctype="multipart/form-data" method="post"
  2.  
  3.   "150" height="30" align="right" valign="middle">请选择上传文件 
  4.   "250">"file" name="fileup" /> 
  5.   "100">"submit" name="submit" value="上传" /> 
  6.  
  7.  
  8. if(!emptyempty($_FILES[fileup][name])){ 
  9.     $fileinfo=$_FILES[fileup]; 
  10.         $type=strstr($fileinfo['name'],"."); 
  11.         if($type!=".jpg"){ 
  12.           echo "您上传的文件格式不正确!"
  13.         }else
  14.           if($fileinfo['size']<209715 && $fileinfo['size']>0){ 
  15.              $path="10/".$_FILES["fileup"]["name"]; 
  16.                  move_uploaded_file($fileinfo['tmp_name'],$path); 
  17.                  if(is_dir("10/")){ 
  18.                    $dir=scandir("10/"); 
  19.                    foreach($dir as $value){ 
  20.                      echo $value."
    "
  21.                    } 
  22.                  }else
  23.                     echo "目录路径出错!"
  24.                  } 
  25.           }else
  26.           echo '文件大小不符合要求!'
  27.           } 
  28.         } 
  29. ?> 

运行结果:

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

方法一:解决办法,

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就可以解决,修改权限命令:

  1. chmod 777 filename 
  2. chmod 777 dirname 
  3. sudo chmod 777 filename/dirname 
  4. chown wangr:admin dirname -R  

注:-R 批量执行


------分隔线----------------------------
------分隔线----------------------------

最新技术推荐