I am trying to download images from a remote server, resize it and then save it to the local computer.
For this I use WideImage.
<?php include_once($_SERVER['DOCUMENT_ROOT'].'libraries/wideimage/index.php'); include_once($_SERVER['DOCUMENT_ROOT'].'query.php'); do { wideImage::load($row_getImages['remote'])->resize(360, 206, 'outside')->saveToFile($_SERVER['DOCUMENT_ROOT'].$row_getImages['local']);} while ($row_getImages = mysql_fetch_assoc($getImages)); ?>
This works most of the time. But he has a fatal flaw.
If for any reason one of these images is not available or does not exist. The Wideimage function causes a fatal error. Prevention of any other images that may exist during upload.
I tried to check a file like this
do { if(file_exists($row_getImages['remote'])){ wideImage::load($row_getImages['remote'])->resize(360, 206, 'outside')->saveToFile($_SERVER['DOCUMENT_ROOT'].$row_getImages['local']);} } while ($row_getImages = mysql_fetch_assoc($getImages));
But that will not work.
What am I doing wrong?
thanks
source share