SHARE
TWEET

PHP: Copy image from remote server to local server

tribulant Feb 21st, 2012 215 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $remoteimage = "http://domain.com/path/to/remote/image.jpg";
  2. $localimage = "/home/domain/httpdocs/path/to/my/image.jpg";
  3.  
  4. if ($content = file_get_contents($remoteimage)) {
  5.         if (!empty($content)) {
  6.                 $fp = fopen($localimage, "w");
  7.                 fwrite($fp, $content);
  8.                 fclose($fp);
  9.         }
  10. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top