[Quickform.php] Deletion of the files in function validate()
| From: | Frederic Poeydomenge | Date: | Mon, 07 Apr 2003 08:10:39 +0000 |
| Subject: | [Quickform.php] Deletion of the files in function validate() | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-14962@lists.php.net to get a copy of this message | ||
In the validate() function, in Quickform.php, the isset($file['tmp_name'])
instruction always returns true, even if no file was uploaded :
myfile Array(4)
+ name String[0] ()
| type String[24] (application/octet-stream)
| tmp_name String[4] (none)
+ size Long (0)
that produces an alert when trying to unlink the file 'none' (Unlink failed (No
such file or directory) in /usr/share/pear/HTML/QuickForm.php on line 1636)
Is this part of code necessary, as PHP is already implementing the mecanism to
delete uploaded files at the end of the request (PHP Manual, Chapter 18.
Handling file uploads) :
"The file will be deleted from the temporary directory at the end of the
request if it has not been moved away or renamed."
And since PHP 4.2.0, PHP returns an appropriate error code along with the file
array, so if this part of code is necessary, the test should be modified :
if (
(isset($file['error']) and $file['error'] == UPLOAD_ERR_OK)
or
(isset($file['tmp_name']) and $file['tmp_name'] != 'none')
) {
Regards,
--------------------
Frederic Poeydomenge