发布数组限制?

问题描述 投票:5回答:3

我在表格输入中发布很多行数据时遇到问题,我只看到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 html
3个回答
7
投票

PHP引入了max_input_vars配置选项,默认值为1000.查看PHP手册的Runtime Configuration部分。

可以通过更新服务器的php.ini,添加.htaccess文件或向httpd.conf添加一行来更改该值。


1
投票

尝试更改max_input_vars。更多信息: PHP max_input_vars and big forms.


1
投票

Rutunj sheladiya告诉你关于max_input_vars限制的所有内容,这是你的主要问题。

我的解决方案是对数组进行json_encode,这样你就只能发送一个编码的字符串。然后在dest服务器中,您必须对数组进行json_decode。

我认为这是一个干净的解决方案,因为它可能是一个巨大的阵列,你不知道它的大小。

现在,如果json编码的字符串的大小高于您配置的值,则仅限于max_post_size。

问候。

© www.soinside.com 2019 - 2024. All rights reserved.