PHP Image size is less than 1mb

纵然是瞬间 提交于 2019-12-04 22:04:23

1MB == 1048576 bytes

1MB == 1024 Kbytes

You question is not clear, but I will just improvise anyhow.

If you want to restrict file uploads to below < 1MB only!! then, since the $_FILES array, will output in bytes you can do the following.

if($_FILES['name']['size'] > 1048576){
  //You can not upload this file
}

Or you want want to restrict it from browser-level, you can add an attribute to your form as

form method="POST" enctype="multipart/form-data">
    <input type="hidden" name="MAX_FILE_SIZE" value="1048576" />
    <input type="file" name="pictures" />
    <input type="submit" value="upload" />
</form>

Offcourse, the second option can be changed by anyone easily, and should never be used.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!