Bug #18581 Updated: Uploaded Files Incorrectly assumed to exist

From: Date: Fri, 26 Jul 2002 02:50:28 +0000
Subject: Bug #18581 Updated: Uploaded Files Incorrectly assumed to exist
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-15258@lists.php.net to get a copy of this message
ID: 18581 Updated by: sniper@php.net Reported By: alexis@mvs.com -Status: Open +Status: Closed Bug Type: *General Issues Operating System: Solaris 7 / RH Linux 7.3 PHP Version: 4.2.2 New Comment: This bug has been fixed in CVS. You can grab a snapshot of the CVS version at http://snaps.php.net/. In case this was a documentation problem, the fix will show up soon at http://www.php.net/manual/. In case this was a PHP.net website problem, the change will show up on the PHP.net site and on the mirror sites. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2002-07-25 22:41:44] alexis@mvs.com In previous versions of PHP (before 4.2.2) when a form was submited containing an <input type="file"> field, if the browsed file size was 0 or if the file specified in the field didn't exist on the submitter's disk, the file name was reported "none" and no temporary file was created on the Server. I tried this with the following script in PHP 4.1.2 and PHP 4.2.2 both running in Solaris 7 Boxes with Apache 1.3 The file name of the script is "file_problem.php". <? if ($_REQUEST["answered"] == "ok") { echo "<pre>"; echo $_SERVER["SERVER_SOFTWARE"] . "\n\n"; echo "These are the contents of the \$_FILES array :: \n"; print_r($_FILES); echo "</pre>"; } else { ?> <form name="forma" action="file_problem.php" method="post" ENCTYPE="multipart/form-data"> <input type="file" name="userfile"> <input type="hidden" name="answered" value="ok"> <input type="submit"> </form> <?}?> ***** When we click on the browse button and select a file from our localdisk this is returned in PHP 4.2.2 : Apache/1.3.26 (Unix) PHP/4.2.2 These are the contents of the $_FILES array :: Array ( [userfile] => Array ( [name] => fetuccinni.jpg [type] => image/pjpeg [tmp_name] => /var/tmp/phpHaaagK [error] => 0 [size] => 12385 ) ) ***** Looks somewhat different to PHP 4.1.2 because of the "error" field but works fine. Apache/1.3.24 (Unix) PHP/4.1.2 These are the contents of the $_FILES array :: Array ( [userfile] => Array ( [name] => ellago.jpg [type] => image/pjpeg [tmp_name] => /var/tmp/phpenaW3e [size] => 10443 ) ) **** When we browse a 0 byte file or type in a bogus file name in the field these are the different results: Apache/1.3.26 (Unix) PHP/4.2.2 These are the contents of the $_FILES array :: Array ( [userfile] => Array ( [name] => typedtext [type] => application/octet-stream [tmp_name] => /var/tmp/phpmxaqgK [error] => 0 [size] => 0 ) ) Apache/1.3.24 (Unix) PHP/4.1.2 These are the contents of the $_FILES array :: Array ( [userfile] => Array ( [name] => typedtext [type] => application/octet-stream [tmp_name] => none [size] => 0 ) ) This is incorrect because PHP assumes the file exists and creates a file in the server. The only way we have to determine if we have to move the file or not is the "size" field, but there is no a way to determine if the user really uploaded a 0 byte file or simply if the file didn't existed in the user disk. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=18581&edit=1

« previous php.bugs (#15258) next »