note 20153 deleted from features.file-upload.common-pitfalls by vincent
| From: | vincent@php.net | Date: | Fri, 12 Sep 2003 13:18:29 +0000 |
| Subject: | note 20153 deleted from features.file-upload.common-pitfalls by vincent | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-56383@lists.php.net to get a copy of this message | ||
Note Submitter: mail@philipp-louis.de
----
If no file was uploaded, you would probably expect the $userfile variable (or whatever its name is)
to be empty. But it isn't. It contains the string "none" instead.
I don't know if this is true for all systems and configurations, but the fact that it *might*
be the case is reason enough *not* to use things like that in order to check whether a file was
uploaded:
// This is bad:
if($userfile == "")
echo "You did not upload any file!";
Instead, you might want to check $userfile_size. But note that this method makes no difference
between NO and an EMPTY file:
// This is better:
if(!$userfile_size)
echo "Either you did not upload any file, or you uploaded an empty file!";