new limit within php: 1000 fields per POST. Does someone know, if the number can be influenced?

后端 未结 9 2014
北荒
北荒 2020-11-27 04:53

In newer PHP-Versions the count of input-fileds per formula (POST) will be limited to 1000 (unverified information). It seams that this limit is already installed in certain

相关标签:
9条回答
  • 2020-11-27 05:00

    I too have come across this issue, working on a localised installation of my code, and Debian Sid has upgraded to 5.4 RC4 PHP. A form of over 7000 lines with checkboxes (!) suddenly only processed 1001 of these in the $_POST data...head scratching for a few hours.

    Made the change in /etc/php5/apache2/php.ini:

    max_input_vars = 5000
    

    save, and restart apache, and it's all good now.

    0 讨论(0)
  • 2020-11-27 05:01
    max_input_vars
    

    is an attempt for PHP to solve some security issues and when set, it limits your number of inputs (thus, fields in your forms). Also beware of

    max_input_nesting_level
    

    And yes - they are configurable. Just edit your php.ini or htaccess values.

    0 讨论(0)
  • 2020-11-27 05:04

    If you do not use multiple or more than 1000 input fields you can be concatenating multiple inputs with any special character, for example @

    <input type='text' name='hs1' id='hs1'>
    <input type='text' name='hs2' id='hs2'>
    <input type='text' name='hs3' id='hs3'>
    <input type='text' name='hs4' id='hs4'>
    <input type='text' name='hs5' id='hs5'>
    
    <input type='hidden' name='hd' id='hd'>
    

    using any script (JavaScript or JScript)

    document.getElementById("hd").value =     document.getElementById("hs1").value+"@"+document.getElementById("hs2").value+"@"+document.getElementById("hs3").value+"@"+document.getElementById("hs4").value+"@"+document.getElementById("hs5").value
    

    with this concept you will be bypass the max_input_vars issue. If you increase the max_input_vars in php.ini file that is harmful to server. Because they use more server cache memory and sometimes they will crash the server.

    0 讨论(0)
  • 2020-11-27 05:05

    These changes tend to be well documented. Are you sure that it's been backported to 5.2? Where did you read so? It seems more likely that you are hitting some other limit such as post_max_size or Apache's LimitRequestFields, or even a PHP security mod like Suhosin.

    (Furthermore, PHP 5.2 is no longer supported, so I doubt it'd receive such upgrade.)

    0 讨论(0)
  • 2020-11-27 05:06

    If you cannot/ do not want to increase the server limit, here is another solution

    <!-- 10000 checkboxes outside the FORM. You do not want to post this -->
    <input class="cbox" type="checkbox" value="1"  id="id-1" checked name="id[]">
    ....
    <input class="cbox" type="checkbox" value="10000"  id="id-10000" checked name="id[]">
    <form method="POST" action="postpage.php">
        <input type="hidden" id="cboxes" name="cboxes" class="cboxes" value="" />
        <input type="submit" onclick="return clicked();">
    </form>
    

    then using jquery

    <script>
    function clicked() {
        var cb = $('.cbox:checked').map(function() {return this.value;}).get().join(',');
        $('#cboxes').val(cb);
        return true;
    }
    </script>
    

    Using POST I tested posting 10000 records.

    In the server

    $cboxes = $_POST['cboxes'];
    $cbox_exp =(explode(',', $cboxes));
    print_r(count($cbox_exp)); //gives me 10000
    
    0 讨论(0)
  • 2020-11-27 05:07

    Apparently it looks like a patch on linux environment causing this issue. If your server has this patch 'suhosin', likely to be the issue. Also its not possible to override this in runtime rather include in your php.ini

    suhosin.post.max_array_depth 
    
    suhosin.post.max_array_index_length 
    
    suhosin.post.max_name_length 
    
    suhosin.post.max_totalname_length 
    
    suhosin.post.max_vars 
    
    suhosin.post.max_value_length 
    
    0 讨论(0)
提交回复
热议问题