Advertisement
tribulant

PHP: Copy image from remote server to local server

Feb 21st, 2012
383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.28 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement