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 check whether the URL is valid, but it hasn't worked!
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 check whether the URL is valid, but it hasn't worked!
If you mean broken as in a 404, and not a corrupt image, you can always use something along the lines of:
A great way to view all your latest broken files is to use cpanel "Error Log" which will show you all the last 300 broken files.
Javascript solution (with involving jQuery, though this should be possible to do without it too):
This works for me 100% :) I test if image exists by file_exists() and if it exists, you will catch corrupted images with this.
If by broken you mean corrupted, changes are the imagecreatefrom{extension} won't be able to read them either:
if the files are there on your server check using file_exists function in php
http://php.net/manual/en/function.file-exists.php