POST Content-Length exceeds the limit

后端 未结 9 2364
盖世英雄少女心
盖世英雄少女心 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: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('');
            }
        });
    });

提交回复
热议问题