php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17530 PHP error mesage "File not uploaded" is unclear and misleading.
Submitted: 2002-05-30 15:26 UTC Modified: 2002-05-30 22:20 UTC
From: sean at digitalspinner dot com Assigned:
Status: Not a bug Package: Output Control
PHP Version: 4.2.1 OS: Linux
Private report: No CVE-ID: None
 [2002-05-30 15:26 UTC] sean at digitalspinner dot com
Visit: 
 
http://www.groupit.org/contribute/demonstrationarea/contenttypes/documents/b.21.html 
 
On this page there is one required file upload field, and 
a second optional field (for an image that can be 
automatically scaled and placed within the summary of the 
contribution). When a document file is specified, and an 
image is not, the error "File not uploaded" is stored 
within $php_errormsg. Presumably this is because the 
contrib_image variable is not set. Since this is not truly 
an error condition I think PHP should NOT log an error for 
this event. I imagine there are many other PHP-based sites 
with optional file upload fields that are now generating 
spurious error messages to site administrators (grin). 
 
This functionality was not evident in 4.1.2 or earlier 
versions. The $php_errormsg should contain actual errors 
only.  Thanks for your time - and thanks for creating such 
a great development language! 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-30 18:27 UTC] mfischer@php.net
Verified, even with current HEAD.

The current code doesn't honor multiple fileloads regarding this error message. I also don't see much benefit in fixing this behaviour because if you're using multiple uploads you have to deal with them individually in the code anyway.

How should the file upload deal with e.g. 5 uploads where only the first,third and fifth fields are actually uploaded with files? Output a message like "No file uploaded for field 2 and 4" ? Certainly not.

There's a reason why track_errors isn't enabled by default.

Unless you come up with a decent real-life sample where it is absolutely needed I don't see any need for it.
 [2002-05-30 22:20 UTC] sean at digitalspinner dot com
Just to clarify, is the current behavior going to remain? 
That is, if an [input type=file] field is left empty 
should I expect PHP to place "No file uploaded" in 
$php_errormsg? If so I can't see the benefit at all. It 
would be similar to PHP placing an error in $php_errormsg 
about a blank [input type=text] field saying "No 
characters entered". 
 
Tracking errors via $php_errormsg can be very useful for 
particular applications. However when junk like "No file 
uploaded" starts creeping in it clouds the intended 
purpose IMHO.
 [2002-09-09 12:28 UTC] J dot Antonio at jaruz dot com
Please remove the "Notice: No file uploaded in Unknown on line 0" notice. I have 5 opcional file fields and cannot continue development because this notice keeps appearing on the screen. I do not want to turn off error logging onto the screen.
 [2002-09-09 13:44 UTC] sandino at sandino dot net
diff -uri php-4.2.2.orig/main/rfc1867.c php-4.2.2/main/rfc1867.c
--- php-4.2.2.orig/main/rfc1867.c	Sat Jul 20 14:17:52 2002
+++ php-4.2.2/main/rfc1867.c	Mon Sep  9 13:28:02 2002
@@ -750,7 +750,7 @@
 			cancel_upload = 0;
 
 			if(strlen(filename) == 0) {
-#ifdef DEBUG_FILE_UPLOAD
+#if 0
 				sapi_module.sapi_error(E_NOTICE, "No file uploaded");
 #endif
 				cancel_upload = UPLOAD_ERROR_D;
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 14:01:30 2024 UTC