note 13056 added to features.file-upload.php
| From: | stewart dot boutcher at webworlds dot net | Date: | Thu, 24 May 2001 13:07:57 +0000 |
| Subject: | note 13056 added to features.file-upload.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-14247@lists.php.net to get a copy of this message | ||
The examples given above do not work for php4.0.4.
You have to use the tmp_name rather than the name.
The actual command sequence to check if the file has uploaded and then move it to where you need it
is something like:
// Pull out the information about this upload.
// You don't need type or size unless you want them.
$userfile = $HTTP_POST_FILES['userfile']['name'];
$type = $HTTP_POST_FILES['userfile']['type'];
$size = $HTTP_POST_FILES['userfile']['size'];
$location = $HTTP_POST_FILES['userfile']['tmp_name'];
// If the upload was successful, then move the tmp file.
// Subsitute ./tmp/$userfile to whatever directory/file you want.
// moveFailed() - whatever you want here to handle move failure.
if($userfile and is_uploaded_file($location))
{ move_uploaded_file($location, "./tmp/$userfile") or moveFailed(); }
One more thing - PHP deletes the temporary file if you don't move it, so don't expect to
test the upload by checking the file is on the system like I did. Thanks for making that clear in
the manual!
E-me is you need assistance with this.
Stewart.
http://www.php.net/manual/en/features.file-upload.php