0

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

enter image description here

But, I get

enter image description here

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Pak Ho Cheung
  • 1,382
  • 6
  • 22
  • 52

1 Answers1

0

You can use ini_set('max_execution_time', 6000); as beginning of the file..By the way you can increase run time of the file..