Where do POSTed files go?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gmcclellan
Forum Newbie
Posts: 2
Joined: Wed Mar 10, 2010 6:57 pm

Where do POSTed files go?

Post 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?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Where do POSTed files go?

Post 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?
gmcclellan
Forum Newbie
Posts: 2
Joined: Wed Mar 10, 2010 6:57 pm

Re: Where do POSTed files go?

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Where do POSTed files go?

Post 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.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Where do POSTed files go?

Post by requinix »

If your script doesn't move or delete the file, PHP will delete it when the script ends.
Post Reply