I need a .PHP script that will download many images from another site. Images - thumbs - each has a size of about 20 KB. I worked on my script, but unfortunately it just lags behind my server and almost kills it, forcing me to restart it.
There are about 100 photos or more per execution, .jpg files, ~ 20 KB / file.
My script:
$count = 0;
foreach ($files as $file) {
$count++;
$url = $file;
$dl_place = '/home/lulz/'.$count.'.jpg';
$ch = curl_init($dl);
$fp = fopen($path, 'wb');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
}
As you can see, I use curl, but I am ready to use something if it works better than now.
source
share