Skip to content

Instantly share code, notes, and snippets.

@IftiMahmud
Created January 21, 2015 21:46
Show Gist options
  • Save IftiMahmud/a24cf262e4db677dc61a to your computer and use it in GitHub Desktop.
Save IftiMahmud/a24cf262e4db677dc61a to your computer and use it in GitHub Desktop.
AutoImageDownloader: Download all images from a server. Works if you know the URL of the images.
<?php
//Auto download all images of an album.
//Works if the images are stored in sequential order in the server. eg: img-01, img-02, img-03 etc.
for ($i=0; $i <=10; $i++) { //capturing first 10 images. change the max value to download more
$d = 'http://example.com/album/image-0'; //first part of the image uri
$e = $i; //image number
$f = '.jpg'; //img extension
$url = $d.$e.$f; //this creates the full images url. eg: http://example.com/album/image-01.jpg
$a = 'pic-'; //Give any name you want. This will be the name part of the downloaded files
$b = $i; //image number
$c = '.jpg';
$img = $a.$b.$c; //full name with extension of the image
file_put_contents($img, file_get_contents($url));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment