$_FILES[“file”][“size”] returning 0?

后端 未结 4 1495
借酒劲吻你
借酒劲吻你 2020-12-18 18:29

I am trying to upload something using PHP and set a limit on the total size that I allow to be uploaded. I want to limit my uploads to 2MB but for some reason whenever I try

4条回答
  •  梦毁少年i
    2020-12-18 19:28

    How I supposed in my previous comment, your problem is that limit of uploadable file in php.ini is less than 7MB.
    So you could try to use

    if ($_FILES["file"]["size"] > 0 && $_FILES["file"]["size"] < 2097152)
    

    Consider that if you put your limit (in php.ini) to 2MB, that check could be easily written as

    if ($_FILES["file"]["size"] > 0)
    

提交回复
热议问题