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

后端 未结 6 1013
余生分开走
余生分开走 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条回答
  •  误落风尘
    2020-12-18 07:29

    Is there any way to have PHP determine whether an image file is broken

    If by broken you mean corrupted, changes are the imagecreatefrom{extension} won't be able to read them either:

    if( imagecreatefromjpeg( $yourfile ) !== false ) {
        // image is okay.
    }
    

提交回复
热议问题