POST Content-Length exceeds the limit

后端 未结 9 2256
盖世英雄少女心
盖世英雄少女心 2020-11-27 11:26

I get similar errors in my error_log in php when users are uploading their files

PHP Warning: POST Content-Length of 11933650 bytes exceeds the limi

相关标签:
9条回答
  • 2020-11-27 12:15

    8388608 bytes is 8M, the default limit in PHP. Those changes to php.ini should indeed solve the problem (make sure your restart your Apache server after making them).

    Memory limit shouldn't need to be changed here.

    0 讨论(0)
  • 2020-11-27 12:17

    There might be more than just one php.ini file. For example, when using WAMP there are 2 php.ini files in following directories:

    • C:\wamp\bin\apache\apache2.4.9\bin
    • C:\wamp\bin\php\php5.5.12

    You need to edit the first one.

    0 讨论(0)
  • 2020-11-27 12:17

    I disagree, but this solution to increase the file size in php.ini or .htaccess, will't work if the user send a file larger than allowed in the server application. I suggest validating this on the frontend. Example:

    $(document).ready(function() {
        $ ('#your_input_file_id').bind('change', function() {
            var fileSize = this.files[0].size/1024/1024;
            if (fileSize > 2) { // 2M
                alert('Your custom message for max file size exceeded');
                $('#your_input_file_id').val('');
            }
        });
    });

    0 讨论(0)
提交回复
热议问题