How to change maximum number of POST variable in PHP?
PHP 5.3.9 introduced the max_input_vars
config option, which is defaulted to a value of 1000. Check out the Runtime Configuration section of the PHP manual. The default value and the change log are at the top of the page.
The value can be changed by updating the server's php.ini, adding an .htaccess file, or adding a line to httpd.conf.
Cannot change PHP post variable limit
Well, it should work after setting max_input_var = 5000 in php.ini. Try to debug it using .htaccess file OR send all the post parameters as a single parameter separated by a unique identifier like "@#" and then split that string in another files using explode function of PHP into an array and use that array for further computation.
OR change your code like this:
<?php
for ($i=1; $i <= 1100; $i++)
{
echo "<input type=text name=a[] value=$i /><br />\n";
}
?>
See I have given same name to all the fields where a is a blank array. When you click on send button, it will send an array in post and then on next page you can use given code to parse all the values
<body>
<?php
$finalarray = $_POST['a'];
$count = count($finalarray);
for ($i=0; $i <= $count; $i++)
{
$num = $finalarray[$i];
echo "Num: $num<br />";
}
?>
</body>
I hope it will work fine.
What is the max size of a single POST variable in PHP?
You need to change your php.ini file
post_max_size = 16M
upload_max_filesize = 16M
memory_limit = 128M
Change these value in php.ini if you've access to it, otherwise you can try to change them in an .htaccess file.
php_value upload_max_filesize 16M
php_value post_max_size 16M
This will work only if the AllowOverride settings permit it. Otherwise, you've to ask to your hosting company.
What is the size limit of a post request?
It depends on a server configuration. If you're working with PHP under Linux or similar, you can control it using .htaccess configuration file, like so:
#set max post size
php_value post_max_size 20M
And, yes, I can personally attest to the fact that this works :)
If you're using IIS, I don't have any idea how you'd set this particular value.
php Post limited to 1000 variables
I see what you did here.
max_input_vars, 1000
Introduced in order to prevent hash collision attack:
http://www.phpclasses.org/blog/post/171-PHP-Vulnerability-May-Halt-Millions-of-Servers.html
But failed in 5.3.9:
http://www.phpclasses.org/blog/post/175-Another-Serious-Security-Bug-on-PHP-539.html
So you should update to 5.3.10+ if that is problem.
Limit of POST arguments in html or php
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?
PHP Limit in POST variables
It would depend on the contents of the array. If it is mostly text, then you could compress/decompress using gzcompress/gzuncompress the resulting serialized object:
$encoded = base64_encode(gzcompress(serialize($original)));
$original = unserialize(gzuncompress(base64_decode($_POST['encoded'])));
gzencode/gzdecode will probably give better compression for larger size data. If your aray contains binary data, or even worse compressed data, then this technique will probably not gain much if anything.
In addition to the PHP configuration already mentioned, your web server can also impose POST size limits, for instance the LimitRequestBody directive in apache: http://httpd.apache.org/docs/2.2/mod/core.html#limitrequestbody
Related Topics
PHP Glob - Scan in Subfolders For a File
How to Import a .SQL File in MySQL Database Using PHP
Call to Undefined Function Curl_Init().
PHP Curl Not Working - Wamp on Windows 7 64 Bit
How to Override the Path of PHP to Use the Mamp Path
Sha1 VS Md5 VS Sha256: Which to Use For a PHP Login
How to Read Last Lines (I.E. "Tail") from a File Using PHP
How to Get Last Key in an Array
Laravel - Eloquent or Fluent Random Row
Read Each Line of Txt File to New Array Element
PHP: If Internet Explorer 6, 7, 8 , or 9
How to Create Multilingual Translated Routes in Laravel
Convert Timestamp to Readable Date/Time PHP
Login Without Https, How to Secure
Super Fast Getimagesize in PHP