Reputation: 249
I have a URL that's in this format
http://site.com/image.php?id=1
Each ID is a different photo, how can I save each image for 1000 ids?
Upvotes: 1
Views: 1334
Reputation: 1292
PHP has an inbuilt function for this, see http://php.net/manual/en/function.copy.php
Upvotes: 1
Reputation: 454922
You can do something like (assuming they are jpg imags and your id's are all consecutive):
for($i=0;$i<=1000;$i++) {
$url = 'http://site.com/image.php?id='.$i;
file_put_contents('image'.$i.'.jpg', file_get_contents($url));
}
Upvotes: 4