faqts : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

21 of 40 people (53%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

How can i save an image from a remote web server to my web server?

Feb 22nd, 2008 20:14
dman, Articles Hosting, Pavel Prishivalko, Bjorn H, http://www.ttnr.org


Here's the snippet:
<?
$url_file = fopen("http://host/image.jpg",'rb');
$newfile_name = "/tmp/mydownload.file";
$newfile = fopen($newfile_name,'wb');
while (!feof($url_file)) {
  $chunk = fread($url_file,1024);
  fwrite($newfile,$chunk);
}
fclose($newfile);
fclose($url_file);
?>
in file "/tmp/mydownload.file" you will have the image you need
=========
openhosting.co.uk/articles/serverside/5854