1

我在我的网站上上传文件时遇到问题,因为我是 php 新手。请帮助我解决这个问题。这是我的代码:当我尝试运行此代码时,它给了我错误 move_uploaded_file(/www.g-dms .com/livelink/livelink.exe?func=ll&objId=59413694&objAction=browse&viewType=1/Lighthouse.jpg) [function.move-uploaded-file]:无法打开流:C:\xampp\phpMyAdmin\filefile 中没有错误。第 30 行的 php

<?php         
      $dir = "/www.g-dms.com/livelink/livelink.exe?func=ll&objId=59413694&objAction=browse&viewType=1/";
      $types = array("image/gif","image/jpeg","image/jpg","application/x-zip-compressed");
//Check to determine if the submit button has been pressed  
    if(isset($_POST['submit'])){
//Shorten Variables  
     $tmp_name = $_FILES['upload']['tmp_name'];
     $new_name = $_FILES['upload']['name'];
//Check MIME Type  
    if (in_array($_FILES['upload']['type'], $types)){
         //Move file from tmp dir to new location
        move_uploaded_file($tmp_name,$dir . $new_name);
        echo "<strong>{$_FILES['upload']['name']} was uploaded sucessfully, we will be touch!</strong>";
        }else{
    //Print Error Message
     echo "<small>File <strong><em>{$_FILES['upload']['name']}</em></strong> was not uploaded</small><br />";
    //Debug  
   $name =  $_FILES['upload']['name'];
   $type =    $_FILES['upload']['type'];  
   $size =    $_FILES['upload']['size'];  
   $tmp =     $_FILES['upload']['name'];
   echo "Name: $name<br/ >Type: $type<br />Size: $size<br />Tmp: $tmp";} }

else{        
     echo '';
}
        ?>
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
      <fieldset>
          <div style="padding-left: 90px;"><input type="file" name="upload" />  </div>  
</fieldset>
<br>  
<input type="submit" name="submit" value="Upload File" />  </center>
</form></div></body></html>
4

2 回答 2

0

目录名称不正确。此外,您需要确保 dir 具有写入权限,使用 chmod 755 dirname 授予它所需的权限。

于 2013-02-21T12:58:27.263 回答
0

这是我见过的最奇怪的目录名称。move_uploaded_file()有两个参数。第一个是$_FILES['upload']['tmp_name']你似乎已经掌握的,第二个是目的地。

于 2013-02-21T12:53:23.627 回答