note 74693 added to features.file-upload.errors
| From: | svenr at selfhtml dot org | Date: | Mon, 23 Apr 2007 22:15:35 +0000 |
| Subject: | note 74693 added to features.file-upload.errors | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-125816@lists.php.net to get a copy of this message | ||
Clarification on the MAX_FILE_SIZE hidden form field and the UPLOAD_ERR_FORM_SIZE error code:
PHP has the somewhat strange feature of checking multiple "maximum file sizes".
The two widely known limits are the php.ini settings "post_max_size" and
"upload_max_size", which in combination impose a hard limit on the maximum amount of data
that can be received.
In addition to this PHP somehow got implemented a soft limit feature. It checks the existance of a
form field names "max_file_size" (upper case is also OK), which should contain an integer
with the maximum number of bytes allowed. If the uploaded file is bigger than the integer in this
field, PHP disallows this upload and presents an error code in the $_FILES-Array.
The PHP documentation also makes (or made - see bug #40387 - http://bugs.php.net/bug.php?id=40387) vague
references to "allows browsers to check the file size before uploading". This, however, is
not true and has never been. Up til today there has never been a RFC proposing the usage of such
named form field, nor has there been a browser actually checking its existance or content, or
preventing anything. The PHP documentation implies that a browser may alert the user that his upload
is too big - this is simply wrong.
Please note that using this PHP feature is not a good idea. A form field can easily be changed by
the client. If you have to check the size of a file, do it conventionally within your script, using
a script-defined integer, not an arbitrary number you got from the HTTP client (which always must be
mistrusted from a security standpoint).
----
Server IP: 217.160.72.57
Probable Submitter: 85.177.213.44
----
Manual Page -- http://www.php.net/manual/en/features.file-upload.errors.php
Edit -- https://master.php.net/note/edit/74693
Del: integrated -- https://master.php.net/note/delete/74693/integrated
Del: useless -- https://master.php.net/note/delete/74693/useless
Del: bad code -- https://master.php.net/note/delete/74693/bad+code
Del: spam -- https://master.php.net/note/delete/74693/spam
Del: non-english -- https://master.php.net/note/delete/74693/non-english
Del: in docs -- https://master.php.net/note/delete/74693/in+docs
Del: other reasons-- https://master.php.net/note/delete/74693
Reject -- https://master.php.net/note/reject/74693
Search -- https://master.php.net/manage/user-notes.php