1

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

1
  • There's probably a time limit on the functions you're using. Show us your code. Commented Jun 20, 2012 at 16:42

3 Answers 3

2

Alternatively, you could change the max_execution_time in your php.ini file so that it matches what you need.

Sign up to request clarification or add additional context in comments.

Comments

2
set_time_limit(0); 

Make sure it's at the top of the document, just after <?php

Comments

1

You should use set_time_limit(0) (php.net) instead.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.