Is there any way to have PHP detect a corrupted image?

后端 未结 6 1015
余生分开走
余生分开走 2020-12-18 07:17

Is there any way to have PHP determine whether an image file is corrupted and will not be able to display properly?

I\'ve tried to check with fopen and

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-18 07:32

    If you mean broken as in a 404, and not a corrupt image, you can always use something along the lines of:

    if (file_exists($imageFileName)) {
      ..
    }
    

提交回复
热议问题