|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #41977 A feature to detect post_max_size exceeded (plus friends)
Submitted: 2007-07-12 15:39 UTC Modified: -
Avg. Score:5.0 ± 0.0
Reproduced:5 of 5 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: mikko dot rantalainen at peda dot net Assigned:
Status: Open Package: Feature/Change Request
PHP Version: 5CVS-2007-07-12 (CVS) OS: Ubuntu Linux 6.06
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: mikko dot rantalainen at peda dot net
New email:
PHP Version: OS:


 [2007-07-12 15:39 UTC] mikko dot rantalainen at peda dot net
As described in if the POST data is greater than post_max_size, then both $_POST and $_FILES are empty. The documentation shows a way using the $_GET array as a workaround to detect the situation. However, such workaround cannot be always used because script author may not be the author of the original form and as such cannot add any GET parameters to said form. A method to identify the situation where the user has exceeded post_max_size is therefore required.

I'm suggesting a generic solution:

Add function get_server_status()

This function returns an integer which is a sum (bit mask) of following constants

/** HTTP input has or had GET parameters */
/** HTTP input has or had POST data */
/** HTTP input has or had uploaded files */
/** post_max_size was exceeded, $_POST and $_FILES are empty */
/** max_filesize was exceeded */
/** memory_limit was exceeded before start of the script */
/** max_input_time exceeded before start of the script */

This way a script could also handle the case there memory_limit was hit because the uploaded file was too big (at least older versions of PHP required at least as much memory as the size of the upload). However, because the memory space that was not enough for file upload is now free to use for PHP, the script should be able to handle the situation using that same memory (e.g. tell the user about the issue in a nice way or redirect to alternative method).

Note that I've named the function get_server_status() instead of get_input_status() or get_http_input_status() so that this same function can be extended in the future for other server/php host status.

Feel free to drop constants/situations that cannot be handled by the script, they are of no use in any case.


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jul 24 15:01:29 2024 UTC