php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62536 file uploads MAX_FILE_SIZE doesn't work as described
Submitted: 2012-07-11 17:10 UTC Modified: 2012-07-13 09:36 UTC
From: danny at tibibi dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.4.4 OS: Windows Server 2008
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: danny at tibibi dot com
New email:
PHP Version: OS:

 

 [2012-07-11 17:10 UTC] danny at tibibi dot com
Description:
------------
The documentation for handling file uploads, http://us3.php.net/manual/en/features.file-upload.post-method.php states that when declaring a hidden field named MAX_FILE_SIZE, if the file submitted is larger, then the user will not have to wait longer to be told that the file was too large.

<?php

if (isset($_POST['MAX_FILE_SIZE']))
{
  echo $_FILES['file1']['error'];
}
?>
<html>
<body>
<form action="/test.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="100" />
<input type="file" name="file1">
<input type="submit" value="submit">
</form>
</body>
</html>

Actual result:
--------------
The complete file gets uploaded however big it is, and the result shows: 2

This confirms that MAX_FILE_SIZE worked, and the file was too large, but it did not stop processing the request after 100 bytes were processed.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-07-12 13:57 UTC] Sjon at hortensius dot net
This feature is meant for clients (eg. browsers), but it seems your browser 
doesn't implement this feature. PHP doesn't do anything with this variable

More info @
http://stackoverflow.com/questions/1381364/max-file-size-in-php-whats-the-point
 [2012-07-12 17:15 UTC] danny at tibibi dot com
Thanks for your comment.

If php doesn't do anything with the variable, then why is it php returns error "2" in the $_FILES array when I set that variable, and upload a file that is smaller than the max_upload_size in the .ini file but larger than the MAX_FILE_SIZE variable I post?
 [2012-07-13 09:26 UTC] Sjon at hortensius dot net
If you read the link I posted, you'll see that PHP _also_ checks for the defined 
MAX_FILE_SIZE and behaves the same as it would with max_upload_size @ini.

So: PHP checks this too, but the client-side advantage isn't implemented in any 
browser (which is also described here: https://bugs.php.net/bug.php?id=40387)
 [2012-07-13 09:36 UTC] maarten@php.net
As explained above, not a PHP bug, merely a client feature made up by PHP and ignored by browsers.
 [2012-07-13 09:36 UTC] maarten@php.net
-Status: Open +Status: Not a bug
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 22 19:01:31 2024 UTC