Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Limit of POST arguments in html or php

Tags:

html

post

php

is there any limit of POST arguments? I have situation where on dev server my form with over 520 args is posted and saved without problems, where on production env it saves only up to 499 args...

Any ideas?

like image 829
spamec Avatar asked Feb 26 '10 11:02

spamec


People also ask

How can change maximum number of POST variable in PHP?

By default, the maximum number of input variables allowed for PHP scripts is set to 1000. You can change this amount by setting the max_input_vars directive in a php. ini file. To verify the current value of the max_input_vars directive and other directives, you can use the phpinfo() function.

What is the default maximum size of POST in PHP INI of?

The default PHP values are 2 MB for upload_max_filesize, and 8 MB for post_max_size.

How much data can you send in POST request?

The default value of the HTTP and HTTPS connector maximum post size is 2MB. However you can adjust the value as per your requirement. The below command to set the connector to accept maximum 100,000 bytes. If the http request POST size exceeds the 100,000 bytes then connector return HTTP/1.1 400 Bad Request.


3 Answers

I don't think there is a limit to the number of variables sent through POST, just on their accumulated size. The limit varies from server to server.

Update: The Suhosin PHP hardening patch can in fact impose a limit on the number of request variables. The default is 2001000. Suhosin is installed by default on Ubuntu, so it could be the reason for your problem. Info courtesy of @Pascal Martin, cheers!

There are two factors to limiting the POST maximum size:

  • The PHP setting post_max_size
  • Indirectly, also the PHP setting max_input_vars

You can find out its value using phpinfo().

And the web server's limits:

  • LimitRequestBody in Apache
  • MaxClientRequestBuffer on IIS

In your specific case, you may want to add what kind of server you are running this on, and how big the data is. Are the 520 arguments coming anywhere near post_max_size? What happens if you do a print_r($_REQUEST) in the receiving script?

like image 114
Pekka Avatar answered Oct 09 '22 17:10

Pekka


Also, in PNP.INI file there is a setting:

max_input_vars

which in my version of PHP: 5.4.16 defaults to 1000.

From the manual: "How many input variables may be accepted (limit is applied to $_GET, $_POST and $_COOKIE superglobal separately)"

Ref.: http://www.php.net/manual/en/info.configuration.php#ini.max-input-vars

like image 43
Nikolay Ivanov Avatar answered Oct 09 '22 16:10

Nikolay Ivanov


Yes, this is controlled by the directive post_max_size, which is 8M by default.

The number of arguments doesn't matter, but you probably exceed the limit in your production.

You can run ini_get('post_max_size') in both environments to see if there is a difference.

You can't change it from ini_set, however it is possible to change the directive from .htaccess.

like image 36
Sagi Avatar answered Oct 09 '22 18:10

Sagi