Home  >  Article  >  Backend Development  >  move_uploaded_file疏失

move_uploaded_file疏失

WBOY
WBOYOriginal
2016-06-13 10:35:101108browse

move_uploaded_file出错
我想上传文件,但是出现:
Warning: move_uploaded_file(z:/document/src/9q6vfjg6nifjok4uc7bcvh36c0.doc): failed to open stream: No such file or directory in E:\www\foxconverter\document\convert-to-pdf.php on line 77 
Warning: move_uploaded_file(): Unable to move 'C:\WINDOWS\Temp\php52.tmp' to 'z:/document/src/9q6vfjg6nifjok4uc7bcvh36c0.doc' in E:\www\foxconverter\document\convert-to-pdf.php on line 77 

html部分:


 

 
 

 
 

 

 
 

 
 
php部分:
    $rootdoc = $_SERVER['DOCUMENT_ROOT'];
  require_once $rootdoc."/db/db.php"; 
  $id =session_id();
  if(($_SERVER['REQUEST_METHOD']=='POST'))
  {
  if(!is_uploaded_file($_FILES['file']['tmp_name']))
  {
  die("");
  }  
  if((($_FILES["file"]["type"]=="text/plain")||
  && ($_FILES["file"]["size"]   {  
  $oldname=$_FILES["file"]["name"];
  $old_arr=explode(".",$oldname);  
  $newname=session_id().".".$old_arr[1];

  //$result2=copy($_FILES["file"]["tmp_name"],"e:/document/src/".$newname);
  //$$result2=move_uploaded_file($_FILES["file"]["tmp_name"],"upload/".$newname);
  $result2=move_uploaded_file($_FILES["file"]["tmp_name"],"z:/document/src/".$newname);
  }
  }
  else
  {
  die("");
  }
?>
我换到别的盘的绝对路径就可以,我使用z盘的绝对路径和使用服务器根目录的相对路径upload的时候就会出现这种错误。
z是从别的机器上映射过来的盘符。

------解决方案--------------------
apache的运行身份是否有权操作z盘?
------解决方案--------------------
探讨

引用:

apache的运行身份是否有权操作z盘?

怎么看apache是否有权限操作z盘,我可以手动在z盘新建文件夹和文件

------解决方案--------------------
PHP code
$result2=move_uploaded_file($_FILES["file"]["tmp_name"],"z:\\document\\src\\".$newname);<br><font color="#e78608">------解决方案--------------------</font><br>你的 z:/document/src 目录存在吗?<br><font color="#e78608">------解决方案--------------------</font><br>上传至根目录下的upload文件夹也报错? 错误信息就是说路径错误的意思啊 ,不会那么奇怪吧。<br><font color="#e78608">------解决方案--------------------<div class="clear">
                 
              
              
        
            </div></font>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn