php上传的文件不存在

我确保/ tmp文件夹是可写的,并且在php.ini中

upload_max_filesize = 5M
post_max_size = 8M

在我的upload.html中

<html>
<body>

<form action="upload_file.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit">
</form>

</body>
</html>

在我的upload_file.php中

<?php
if ($_FILES["file"]["error"] > 0)
  {
  echo "Error: " . $_FILES["file"]["error"] . "<br>";
  }
else
  {
  echo "Upload: " . $_FILES["file"]["name"] . "<br>";
  echo "Type: " . $_FILES["file"]["type"] . "<br>";
  echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
  echo "Stored in: " . $_FILES["file"]["tmp_name"];
  move_uploaded_file ($_FILES["file"]["tmp_name"] , '/var/www/html/web' );
  }
?> 

这是输出

Upload: screenshot 2013-12-30 15:00:54.png
Type: image/png
Size: 201.8154296875 kB
Stored in: /tmp/phpEdIgXr 

但/ tmp / phpEdIgXr不存在!

最佳答案 只需将代码放在下面然后尝试.它可能对你有所帮助.

if ($_FILES["file"]["error"] > 0)
    {
        echo "Apologies, an error has occurred.";
        echo "Error Code: " . $_FILES["file"]["error"];
    }
    else
    {
        move_uploaded_file($_FILES["file"]["tmp_name"],"[YOUR FOLDER PATH]".$_FILES["file"]["name"]); 
    }
点赞