#17530 [Com]: PHP error mesage "File not uploaded" is unclear and misleading.

From: Date: Mon, 09 Sep 2002 18:44:42 +0000
Subject: #17530 [Com]: PHP error mesage "File not uploaded" is unclear and misleading.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-18836@lists.php.net to get a copy of this message
ID: 17530 Comment by: sandino@sandino.net Reported By: sean@digitalspinner.com Status: Bogus Bug Type: Output Control Operating System: Linux PHP Version: 4.2.1 New Comment: 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; Previous Comments: ------------------------------------------------------------------------ [2002-09-09 12:28:29] J.Antonio@jaruz.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-05-30 22:20:26] sean@digitalspinner.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-05-30 18:27:53] 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 15:26:19] sean@digitalspinner.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! ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=17530&edit=1

« previous php.bugs (#18836) next »