我在表格输入中发布很多行数据时遇到问题,我只看到500行。
这里是我的细节代码:
<?php
if($_POST){
echo '<pre>';
print_r($_POST);
echo '</pre>';
}
?>
<form method="post" enctype="multipart/form-data" >
<table>
<tr>
<td>Value</td>
<td>Name</td>
</tr>
<?php for($i=1;$i<=1000;$i++){?>
<tr>
<td><input type="input" name="attributes[<?= $i ?>][value]" value="<?= $i ?>" /></td>
<td><input type="input" name="attributes[<?= $i ?>][name]" value="<?= 'name'. $i ?>" /></td>
</tr>
<?php } ?>
</table>
<input type="submit"/>
</form>
PHP引入了max_input_vars配置选项,默认值为1000.查看PHP手册的Runtime Configuration部分。
可以通过更新服务器的php.ini,添加.htaccess文件或向httpd.conf添加一行来更改该值。
Rutunj sheladiya告诉你关于max_input_vars限制的所有内容,这是你的主要问题。
我的解决方案是对数组进行json_encode,这样你就只能发送一个编码的字符串。然后在dest服务器中,您必须对数组进行json_decode。
我认为这是一个干净的解决方案,因为它可能是一个巨大的阵列,你不知道它的大小。
现在,如果json编码的字符串的大小高于您配置的值,则仅限于max_post_size。
问候。