This sounds like a stupid question but, after uploading a file the file isnt in the location php said it would be.
First the simple test page:
<html><body>
<h1><?=$_FILES['imgup']['tmp_name'];?></h1>
<?
print_r($_FILES);
?>
<form enctype="multipart/form-data" method="post" action="upload.php">
<input type="file" name="imgup" id="imgup">
<input type="submit">
</form>
</body></html>
Now, the print_r in plain text:
Array ( [imgup] => Array ( [name] => ace.jpg [type] => image/jpeg [tmp_name] => /tmp/phpEdfBjs [error] => 0 [size] => 29737 ) )
So no error, standard looking path, but /tmp has no such file. Further, running a find on my whole system turns up bubkis.
FYI: php.ini has
max_execution_time = 120
file_uploads = On
upload_max_filesize = 2M
and the file I've been uploading is 29k
Any thoughts?
The temporary file is deleted when the PHP script that received it has finished running : it is just a temporary file.
The PHP script to which you are posting the form -- upload.php -- should move the temporary file to a non-temporary location, using move_uploaded_file()
Basically, the idea is :
If the upload doesn't finish successfully, or if you don't move the file somewhere else, the temporary file is automatically deleted.
As a reference, you should read the following section of the manual : Handling file uploads - POST method uploads
Quoting the part of it which is related to your problem :
The file will be deleted from the temporary directory at the end of the request if it has not been moved away or renamed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With