Dss.Lexius Posted June 11, 2010 Share Posted June 11, 2010 Hi, i am just new to PHP and need some help. i hope i 'll get. actually, i want to automate my work. there are some images hosted on a server (around 10 images) i have their links. i want to download those images (*.jpg & *.gif files) to my local server in some directory! can anyone help me? Thanks! Link to comment https://forums.phpfreaks.com/topic/204506-download-some-images-from-link-to-local-server/ Share on other sites More sharing options...
litebearer Posted June 11, 2010 Share Posted June 11, 2010 this thread may help http://www.phpfreaks.com/forums/index.php/topic,299809.msg1419172.html#msg1419172 Link to comment https://forums.phpfreaks.com/topic/204506-download-some-images-from-link-to-local-server/#findComment-1070866 Share on other sites More sharing options...
Dss.Lexius Posted June 11, 2010 Author Share Posted June 11, 2010 can you modify this to download multiple images using variables <?php $image_get = "http://www.39dollarglasses.com/store/images/thumb/2164_Brown.jpg"; $image_save = "some_name.jpg"; $i = file_get_contents($image_get); $f = fopen($image_save,'w+'); fwrite($f,$i); fclose($f); ?> something like this $image_get[0] = "http://www.site.com/store/images/1_a.jpg"; $image_get[1] = "http://www.site.com/store/images/2_b.jpg"; and then save them with their original name as got from download link. ? Link to comment https://forums.phpfreaks.com/topic/204506-download-some-images-from-link-to-local-server/#findComment-1070873 Share on other sites More sharing options...
litebearer Posted June 11, 2010 Share Posted June 11, 2010 Perhaps... <?php $image_get[0] = "http://nstoia.com/grs/easyalbum/images/adrian.jpg"; $image_get[1] = "http://nstoia.com/grs/easyalbum/images/beverly.jpg"; $image_get[2] = "http://nstoia.com/grs/easyalbum/images/dog.jpg"; $image_get[3] = "http://nstoia.com/grs/easyalbum/images/group.jpg"; $image_get[4] = "http://nstoia.com/grs/easyalbum/images/kids.jpg"; $image_get[5] = "http://nstoia.com/grs/easyalbum/images/kenny.jpg"; $count = count($image_get); $i=0; while($i<$count) { $image_save = substr(strrchr($image_get[$i], "/"), 1); $image = file_get_contents($image_get[$i]); $f = fopen($image_save,'w+'); fwrite($f,$image); fclose($f); $i++; } ?> Link to comment https://forums.phpfreaks.com/topic/204506-download-some-images-from-link-to-local-server/#findComment-1070962 Share on other sites More sharing options...
Dss.Lexius Posted June 11, 2010 Author Share Posted June 11, 2010 why it takes too long to download only 5 images? can't it be fast? Link to comment https://forums.phpfreaks.com/topic/204506-download-some-images-from-link-to-local-server/#findComment-1070969 Share on other sites More sharing options...
litebearer Posted June 12, 2010 Share Posted June 12, 2010 the speed for that is dependent upon your connection and the server the pics are on. that script took less than 2 seconds Link to comment https://forums.phpfreaks.com/topic/204506-download-some-images-from-link-to-local-server/#findComment-1070980 Share on other sites More sharing options...
Dss.Lexius Posted June 12, 2010 Author Share Posted June 12, 2010 Well, Thank you so much. This problem has been solved. Link to comment https://forums.phpfreaks.com/topic/204506-download-some-images-from-link-to-local-server/#findComment-1071053 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.