Created
January 21, 2015 21:46
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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