5

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?

William Perron
  • 485
  • 7
  • 16
spamec
  • 301
  • 1
  • 5
  • 15

5 Answers5

13

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:

You can find out its value using phpinfo().

And the web server's limits:

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?

Nisse Engström
  • 4,738
  • 23
  • 27
  • 42
Pekka
  • 442,112
  • 142
  • 972
  • 1,088
  • That kind of limit can be implemented by suhoshin (see http://www.hardened-php.net/suhosin/configuration.html#suhosin.post.max_vars for instance -- but the default value is 200, and not 500) ;; and suhosin is installed by default on Ubuntu, for instance. – Pascal MARTIN Feb 26 '10 at 11:40
  • @Pascal very good to know, thank you! Updating the answer accordingly. – Pekka Feb 26 '10 at 11:41
  • you're welcome :-) ;;; I've seen suhosin cause that kind of problems more than a couple of times, so thought it might be an idea ;-) *(and your answer was already better than what I would have posted ^^ )* – Pascal MARTIN Feb 26 '10 at 11:55
  • I already tried post_max_size, but I doesnt work. When print_r, I see exacly number of args on both machines. In fact, production hsa suhosin installed, I'll check and give u info. – spamec Feb 26 '10 at 13:18
  • @spamec if you get all the data in `print_r` them the problem is in your script, not a PHP or other setting. – Pekka Feb 26 '10 at 15:03
  • 2
    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)" http://www.php.net/manual/en/info.configuration.php#ini.max-input-vars – Nikolay Ivanov Nov 08 '13 at 12:52
4

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

Nikolay Ivanov
  • 5,159
  • 1
  • 26
  • 22
1

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.

Sagi
  • 8,009
  • 3
  • 26
  • 25
0

i think the POST limit is whatever is configured in php.ini (8M by default?)

Skay
  • 9,343
  • 6
  • 27
  • 28
0

You need to increase POST_MAX_SIZE in php.ini (or use ini_set() on the page).

http://uk.php.net/manual/en/ini.core.php#ini.post-max-size