I have a script to download image from China server, so image might not be able to download correctly like only partial image shown because of CDN. Guess because of timeout?
Any ways to check image is not downloaded completely?
$content
would not equal to FALSE
if partial image is downloaded
function addNewFile($url) {
$newFileName = 'newFileName.png';
$content = @file_get_contents($url);
if ($content === FALSE) {
echo ' - sleep 30 seconds and try again... ' . "\n";
sleep(30);
return addNewFile($url);
} else {
file_put_contents($newFileNameInLocal, $content);
}
}
Correct image should be
But, I get