note 20153 added to features.file-upload.common-pitfalls

From: Date: Sun, 24 Mar 2002 19:14:54 +0000
Subject: note 20153 added to features.file-upload.common-pitfalls
Groups: php.notes 
Request: Send a blank email to php-notes+get-28150@lists.php.net to get a copy of this message
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!"; -- http://www.php.net/manual/en/features.file-upload.common-pitfalls.php http://master.php.net/manage/user-notes.php?action=edit+20153 http://master.php.net/manage/user-notes.php?action=delete+20153 http://master.php.net/manage/user-notes.php?action=reject+20153

« previous php.notes (#28150) next »