I am working to download images from a website and there comes an error saying "Maximum execution time of 30 seconds exceeded" and the downloading of images stopped. And I tried to add the following line of code that I thought could solve the problem:
ini_set('max_execution_time', 0); //zero means forever I think, I also tried 200 or 300 seconds
And it didn’t give me errors BUT the execution stopped (I mean the images stop downloading).
How can I make the execution time extend like 300 seconds? Is there any solution for this?
Thanks in advance!
Edit:
function save_image($inPath,$outPath)
{
$in= fopen($inPath, "rb");
$out= fopen($outPath, "wb");
while ($chunk = fread($in,8192))
{
fwrite($out, $chunk, 8192);
}
fclose($in);
fclose($out);
}
And a method call:
foreach($li->find('a[class=thumbnail]') as $img)
{
foreach($img->find('img') as $e)
{
$image++;
echo "<img src=\"" . $e->src . "\"/>" . "<br>";
save_image($e->src, 'thumbs/image'. $image .'.JPG');
}
}
That is the code that I’m using
Alternatively, you could change the
max_execution_timein your php.ini file so that it matches what you need.