错误"无法移动文件..."在尝试上传图片时

时间:2016-08-14 18:15:34

标签: php

当我尝试上传图片时,我一直收到此错误。

  

警告:move_uploaded_file(upload / 12fbb74863264bfc30324c64163e5e51.jpg)[function.move-uploaded-file]:无法打开流:第60行/home/a7819363/public_html/login/profile.php中没有此类文件或目录< / p>

PHP错误消息

  

警告:move_uploaded_file()[function.move-uploaded-file]:无法移动&#39; / tmp / phptGBJ2h&#39;到&#39;上传/ 12fbb74863264bfc30324c64163e5e51.jpg&#39;在/home/a7819363/public_html/login/profile.php第60行

<?php

include('fig.php');
if($_POST) { 
 // $_FILES["file"]["error"] is HTTP File Upload variables $_FILES["file"] "file" is the name of input field you have in form tag.
  if ($_FILES["file"]["error"] > 0) {
    // if there is error in file uploading 
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
  } else {
    // check if file already exit in "images" folder.
    if (file_exists("upload/" . $_FILES["file"]["name"])) {

    } else {  
      //move_uploaded_file function will upload your image. 
      if(move_uploaded_file($_FILES["file"]["tmp_name"],"upload/" . $_FILES["file"]["name"])) {
        // If file has uploaded successfully, store its name in data base
        $query_image = "insert into profile_table";
        if(mysql_query($query_image)) {
          echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
        } else {
          echo'';
        }
      }
    }
  }
}

?>

0 个答案:

没有答案