0

I'm trying to post a large form through php using POST method. My form post script has been working fine until now that the $_POST array got pretty large.

When i print out file_get_contents('php://input'); ,all the inputs that are included in the form, are shown. But when i print out $_POST, it only gets the first part of the form. I've tried to remove rows and then the $_POST method works fine again. As soon as it gets too large, it won't post all data included in the form.

Anyone got any ideas? I've tried to edit php.ini and set post_max_size to a higher value, but it didn't help either.

Sestertius
  • 1,367
  • 1
  • 14
  • 13
user2994294
  • 81
  • 1
  • 14

3 Answers3

3

By default, in lower versions of PHP(< 5.3.9) the number of $_POST variables is limited to 1000. There is no way to change that.

In higher versions you can set max_input_vars to whatever number you wish.

If you're below 5.3.9 there are some work-arounds you can do. For example json_encode the variables and send them as a single variable. The limit of $_POST is set to 8mb by default but can be changed in the php.ini file post_max_size="whatever_size_you_wish_here".

How to increase the number of variables in $_POST:

2 options:

  • in your .htaccess file do php_value max_input_vars 2000(or whatever)

  • in the file you're working with ini_set('max_input_vars', 2000);

Andrei
  • 3,434
  • 5
  • 21
  • 44
1

Try dumping a phpinfo() and look for max_input_vars. If it's there, you can set it in php.ini to a higher number, as you see fit. If you don't see it, it's likely that you didn't receive that exact patch and the number has been hard-coded by your distribution.

0

Just solved it, apparently my server didn't update max_input_vars for some strange reason. Now that i increased that value it's working.

user2994294
  • 81
  • 1
  • 14