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!
Download some images from link to local server
Moderator: General Moderators
-
Dss.Lexius
- Forum Newbie
- Posts: 11
- Joined: Fri Jun 11, 2010 12:18 pm
-
Dss.Lexius
- Forum Newbie
- Posts: 11
- Joined: Fri Jun 11, 2010 12:18 pm
Re: Download some images from link to local server
Ok, before anyone reply
i have got it, but still need some help
can anyone modify this to download multiple images using variables
something like this
and then save them with their original name as got from download link.
?
i have got it, but still need some help
can anyone modify this to download multiple images using variables
Code: Select all
<?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);
?> Code: Select all
$image_get[0] = "http://www.site.com/store/images/1_a.jpg";
$image_get[1] = "http://www.site.com/store/images/2_b.jpg";?
-
lunarnet76
- Forum Commoner
- Posts: 67
- Joined: Sun Apr 04, 2010 2:07 pm
- Location: Edinburgh
Re: Download some images from link to local server
you have an array so
you declare an array containing ALL your images URL
at the beginning then you read your all array and for each image you download it
hope it helps!
you declare an array containing ALL your images URL
Code: Select all
$image_get =array( "http://www.site.com/store/images/1_a.jpg", "http://www.site.com/store/images/2_b.jpg");Code: Select all
foreach($image_get as $image){
$i = file_get_contents($image);
$f = fopen($image_save,'w+');
fwrite($f,$i);
fclose($f);
}-
Dss.Lexius
- Forum Newbie
- Posts: 11
- Joined: Fri Jun 11, 2010 12:18 pm
Re: Download some images from link to local server
Thanx, but i have 10 images. how do i put 10 links in array?
do i have to add all links in one line? the line 'll get very bigger...
do i have to add all links in one line? the line 'll get very bigger...
-
whiteulver
- Forum Newbie
- Posts: 3
- Joined: Fri Jul 17, 2009 7:36 pm
Re: Download some images from link to local server
Use it like this
Code: Select all
$image_get =array(
"http://www.site.com/store/images/1_a.jpg",
"http://www.site.com/store/images/2_b.jpg",
"http://www.site.com/store/images/3_c.jpg",
"http://www.site.com/store/images/4_d.jpg"
);