Jump to content

Download some images from link to local server


Dss.Lexius

Recommended Posts

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!

 

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.

 

?

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++;
}
?> 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.