No_name
No_name

Reputation: 2810

php uploaded file does not exist

I've made sure that the /tmp folder is writeable, and in php.ini

upload_max_filesize = 5M
post_max_size = 8M

and in my 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>

and in my 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' );
  }
?> 

This is the output

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

but /tmp/phpEdIgXr does not exist!

Upvotes: 4

Views: 8384

Answers (2)

Faron
Faron

Reputation: 1243

For any upload files to surface in a directory, you need to chmod 777 that folder.

Upvotes: 0

King-of-IT
King-of-IT

Reputation: 578

Just put below code and try. it might be helpful to you.

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"]); 
    }

Upvotes: 2

Related Questions