|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2002-07-25 22:50 UTC] sniper@php.net
 | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 06:00:01 2025 UTC | 
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.