How to prevent Warning: POST Content-Length and memory size

前端 未结 7 607
慢半拍i
慢半拍i 2020-12-10 14:46

Currently when user uploads a photo the page says \"Warning: POST Content-Length of XXX bytes exceeds the limit of 21000000 bytes in Unknown on line 0\".

I

相关标签:
7条回答
  • 2020-12-10 15:29

    The question is

    How to prevent Warning: POST Content-Length

    the answer is, without edit any config value, put this code at the very start of the file that will receive the form to be processed:

     <?php // here start your php file
     ob_get_contents();
     ob_end_clean();
    

    That is. No more warning, as well anything else you do not want as output on your page. After, as suggested elsewhere you can decide what to do with:

    if($_SERVER['REQUEST_METHOD'] == 'POST' && empty($_POST) && empty($_FILES) && $_SERVER['CONTENT_LENGTH'] > 0){ echo"WoW your file is too big!"; }
    

    Maybe also chunk the file, if in another way you pass correct values about file to be processed by Php.

    as explained here Warning: POST Content-Lenght ...

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