Piotr Piotr - 1 year ago 55
PHP Question

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

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

and check whether the URL is valid, but it hasn't worked!

Answer Source

Javascript solution (with involving jQuery, though this should be possible to do without it too):

<script type='text/javascript'>
        var files = [
        for ( var n in files ) {
            var img = $('<img/>');
                alert('error:\n' + this.src);
                alert('success:\n' + this.src);
            img.attr('src', files[n]);