[PHP-DOC] #21964 [Opn->Ana]: Uploads of a file with size 0 bytes succeed. From: sniper <email protected>
Date: 02/03/03

 ID: 21964
 Updated by: sniper <email protected>
 Reported By: johnson <email protected>
-Status: Open
+Status: Analyzed
-Bug Type: Filesystem function related
+Bug Type: Documentation problem
 Operating System: ANY
 PHP Version: ANY
 New Comment:

nicos <email protected>: 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.

Previous Comments:
------------------------------------------------------------------------

[2003-02-01 05:06:07] nicos <email protected>

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 <email protected>

I believe this was fixed in 4.2.3 and later.

------------------------------------------------------------------------

[2003-01-30 10:47:31] johnson <email protected>

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

-- PHP Documentation Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php