php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #21964 Uploads of a file with size 0 bytes succeed.
Submitted: 2003-01-30 10:47 UTC Modified: 2005-09-02 14:15 UTC
From: johnson at nicusa dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: ANY
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: johnson at nicusa dot com
New email:
PHP Version: OS:

 

 [2003-01-30 10:47 UTC] 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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-30 11:43 UTC] iliaa@php.net
I believe this was fixed in 4.2.3 and later.
 [2003-02-01 05:06 UTC] 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-02-03 01:01 UTC] 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.


 [2005-09-02 07:53 UTC] sniper@php.net
And iirc, nowadays you don't get any error (if your PHP is not compiled with --enable-debug :)

 [2005-09-02 14:15 UTC] vrana@php.net
Error #5 is not documented so everything should be fine.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Sep 15 08:00:01 2025 UTC