Page 1 of 1

Where do POSTed files go?

Posted: Wed Mar 10, 2010 7:11 pm
by gmcclellan
I am extending an existing PHP program that POSTs a file from the user's PC to a Linux server. The problem is I can't find where on the server the uploaded file is stored. I need to find the file so I can operate on it.

The initial PHP page uses this code to POST the file:

Code: Select all

<form method="post" enctype='multipart/form-data' action="upload.php">
<input type=file name=thefile>
<input type="submit" VALUE="Upload" name="Upload">
</form>
The upload.php file receives the POST and the stores the name of the file in $_FILES['thefile']['name'].

Further, $_FILES['thefile']['tmp_name'] contains /tmp/phpRCaphU. The problem I have is that there is no such file as /tmp/phpRCaphU.

Can any suggest where I may find the POSTed file?

Re: Where do POSTed files go?

Posted: Wed Mar 10, 2010 7:19 pm
by requinix
gmcclellan wrote:The problem I have is that there is no such file as /tmp/phpRCaphU.
How did you check that? Has move_uploaded_file complained?

Re: Where do POSTed files go?

Posted: Wed Mar 10, 2010 10:09 pm
by gmcclellan
Q: How did you check that the uploaded file doesn't exist?

# ls -l /tmp/phpRCaphU
ls: cannot access /tmp/phpRCaphU: No such file or directory

Re: Where do POSTed files go?

Posted: Wed Mar 10, 2010 10:16 pm
by John Cartwright
gmcclellan wrote:Q: How did you check that the uploaded file doesn't exist?

# ls -l /tmp/phpRCaphU
ls: cannot access /tmp/phpRCaphU: No such file or directory
They are temporary files, and will only exist within the timeframe of your garbage collector. You generally want to move these files immediately after their upload to a permanent storage location.

Re: Where do POSTed files go?

Posted: Wed Mar 10, 2010 11:04 pm
by requinix
If your script doesn't move or delete the file, PHP will delete it when the script ends.