Detect if uploaded file is too large

前端 未结 4 1266
悲哀的现实
悲哀的现实 2020-12-07 01:10

This is my upload form:

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-07 02:08

    You should set the max allowed file size more than 5M, then with PHP check if the file size exceed 5M. Make sure your webserver post body size is updated with the new size as well.

    Limiting file size based on php ini is not the best solution, because it will limit you. What if you want to check another file not exceed 3MB in another script?

     if ($_FILES['fileupload']['size'] > 5242880) // 5242880 = 5MB
          echo 'your file is too large';
    

提交回复
热议问题