#21964 [Ana->Csd]: Uploads of a file with size 0 bytes succeed.

From: Date: Fri, 02 Sep 2005 12:15:16 +0000
Subject: #21964 [Ana->Csd]: Uploads of a file with size 0 bytes succeed.
References: 1  Groups: php.doc 
Request: Send a blank email to phpdoc+get-969369833@lists.php.net to get a copy of this message
ID: 21964 Updated by: vrana@php.net Reported By: johnson at nicusa dot com -Status: Analyzed +Status: Closed Bug Type: Documentation problem Operating System: ANY PHP Version: Irrelevant New Comment: Error #5 is not documented so everything should be fine. Previous Comments: ------------------------------------------------------------------------ [2005-09-02 07:53:11] sniper@php.net And iirc, nowadays you don't get any error (if your PHP is not compiled with --enable-debug :) ------------------------------------------------------------------------ [2003-02-03 01:01:28] sniper@php.net nicos@php.net: don't try analyzing any bugs as you obviously don't have a clue. For doc people: With PHP 4.3.0 -> you can upload 0 byte files and you don't get any error. There is no error code '5'. You get error 4 (UPLOAD_ERR_NO_FILE) if you don't put any file in the <input type=file..> field. ------------------------------------------------------------------------ [2003-02-01 05:06:07] nicos@php.net Actually it looks more than a documentation problem: For now there is not any define(name) for the new error code. Plus it looks it's under a #ifdef that can't happen because of : #undef DEBUG_FILE_UPLOAD in line 39 of main/rfc1867.c. There is the code: #ifdef DEBUG_FILE_UPLOAD if(strlen(filename) > 0 && total_bytes == 0) { sapi_module.sapi_error(E_WARNING, "Uploaded file size 0 - file [%s=%s] not saved", param, filename); cancel_upload = 5; } #endif You can note that usually #ifdef DEBUG_FILE_UPLOAD is used only to hide the sapi_module.sapi_error() function not the whole code. eg: if(strlen(filename) == 0) { #ifdef DEBUG_FILE_UPLOAD sapi_module.sapi_error(E_NOTICE, "No file uploaded"); #endif cancel_upload = UPLOAD_ERROR_D; } There is also an another point, why a file with 0 byte has to be cancelled? Has it been discussed? According to melvyn: why would php stop me to upload a file of 0 bytes? Take a 'web-ftp' for like a sitebuilder kinda app it would just upload these and create a 0 byte file, which is what I expect it to do for instance: config.php in phpBB2 is 0 bytes outof the box. it needs that to be, for install to work. So now there are some questions, does the code 5 ever happen? If yes is it expected that it stops the upload and why do not give it a real name so we can finally document it. ------------------------------------------------------------------------ [2003-01-30 11:43:59] iliaa@php.net I believe this was fixed in 4.2.3 and later. ------------------------------------------------------------------------ [2003-01-30 10:47:31] johnson at nicusa dot com I have seen in various places, postings that an uploaded file with size of 0 bytes should now fail. In version 4.2.2 on Solaris 8 it succeeds. Please make clear in the documentation exactly when/in which version of PHP this was changed to throw an error code 5. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=21964&edit=1

« previous php.doc (#969369833) next »