Page 1 of 1
save images from server
Posted: Tue Dec 12, 2006 8:40 am
by gruber99
hi,
how can i save a image from an other (foreign) server (accassable form a browser) - e.g.
http://www.example.com/images77.gif with php ?
thanx
gruber99
Posted: Tue Dec 12, 2006 8:51 am
by neophyte
Is it legal?
Posted: Tue Dec 12, 2006 10:20 am
by William
If you tend to use this legally, here you go.
Code: Select all
<?php
// *** Image to retrieve.
$image = 'http://www.example.com/images77.gif';
$new_file_name = 'image.gif';
// *** Retrieve image contents.
$src = file_get_contents($image);
##### Create new file #####################################
$Fconn = fopen($new_file_name, 'w');
fwrite($Fconn, $src);
fclose($Fconn);
###########################################################
?>
Use it at your own risk! Don't download any copyrighted images.