如何在 PHP 中增加最大 POST 变量?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9399315/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to increase maximum POST variable in PHP?
提问by Anantha Krishnan
I'm using WAMP in my local machine, when a FORM(method="POST") with 2000 input fields is submitted I'm able to read only 1001 _POST variable. i.e With Netbeans debugger I can clearly see _POST size is always 1001 if there are more than 1001 input fields in the form.
我在本地机器上使用 WAMP,当提交具有 2000 个输入字段的 FORM(method="POST") 时,我只能读取 1001 _POST 变量。即使用 Netbeans 调试器我可以清楚地看到 _POST 大小总是 1001,如果表单中有超过 1001 个输入字段。
I used this http://ideone.com/GAw14java code to generate form with N input fields and tested.
我使用这个http://ideone.com/GAw14java 代码生成带有 N 个输入字段的表单并进行了测试。
The same is working fine in another machine(WAMP), where I can see all the POST variables.
同样在另一台机器(WAMP)中工作正常,在那里我可以看到所有的 POST 变量。
Please help me to solve my problem.
请帮我解决我的问题。
回答by lightster
PHP 5.3.9 introduced the max_input_vars
config option, which is defaulted to a value of 1000. Check out the Runtime Configurationsection of the PHP manual. The default value and the change log are at the top of the page.
PHP 5.3.9 引入了max_input_vars
config 选项,默认值为 1000。查看PHP 手册的运行时配置部分。默认值和更改日志位于页面顶部。
The value can be changed by updating the server's php.ini, adding an .htaccess file, or adding a line to httpd.conf.
可以通过更新服务器的 php.ini、添加 .htaccess 文件或在 httpd.conf 中添加一行来更改该值。
回答by jprofitt
If you are using Suhosinwith Hardened PHP, you might be hitting a maximum variables limit that it imposes. In your php.ini, you can just add
如果您将Suhosin与 Hardened PHP一起使用,您可能会遇到它强加的最大变量限制。在你的 php.ini 中,你可以添加
[suhosin]
suhosin.request.max_vars = 1000
suhosin.post.max_vars = 1000
changing 1000
to whatever you want and restart your webserver.
更改1000
为您想要的任何内容并重新启动您的网络服务器。
I ran into this on the Drupal Permissions page when there were a lot of modules installed with a large number of roles, which resulted in a ton of checkboxes. It would only save a certain number of them before anything after would just get ignored.
当安装了大量具有大量角色的模块时,我在 Drupal 权限页面上遇到了这个问题,这导致了大量复选框。它只会保存一定数量的它们,然后才会被忽略。
It sounds like this is probably not your problem, but since it's fairly likely that someone in the future may stumble upon this when searching for something related I'll go ahead and throw this in since it took me ages to figure out when I was stumped.
听起来这可能不是您的问题,但是由于将来有人在搜索相关内容时很可能会偶然发现此问题,因此我会继续将其放入,因为我花了很长时间才弄清楚何时被难倒.
回答by JaPeK
I solved my $_POST max inputs -problem by adding the following to php.ini:
我通过将以下内容添加到 php.ini 解决了我的 $_POST 最大输入问题:
max_input_vars = 5000
suhosin.request.max_vars = 5000
suhosin.post.max_vars = 5000
Note the suhosin.request.max_vars also.
还要注意 suhosin.request.max_vars 。
回答by Robson Mtos
I solved this problem. Open the PHP.INI configuration file and add these lines
我解决了这个问题。打开 PHP.INI 配置文件并添加这些行
[suhosin]
[suhosin]
suhosin.post.max_vars = 20000
suhosin.post.max_vars = 20000
suhosin.request.max_vars = 20000
suhosin.request.max_vars = 20000
回答by Aleks G
I suspect the problem is with the amount of data coming with your POST request. There is no setting which limits the number of $_POST vars that can be set. However there is a memory limit for POST data which is 8MB by default.
我怀疑问题在于您的 POST 请求附带的数据量。没有设置限制可以设置的 $_POST 变量的数量。但是,POST 数据的内存限制默认为 8MB。
In your php.ini file try modifying the value of post_max_size
and set it to a higher value. Don't forget to restart apache after the change is made.
在您的 php.ini 文件中尝试修改 的值post_max_size
并将其设置为更高的值。更改完成后不要忘记重新启动 apache。