get remote image with curl

  1. <?php
  2. $ch = curl_init ("http://static.php.net/www.php.net/images/php.gif");
  3. curl_setopt($ch, CurlOPT_HEADER, 0);
  4. curl_setopt($ch, CurlOPT_RETURNTRANSFER, 1);
  5. curl_setopt($ch, CurlOPT_BINARYTRANSFER,1);
  6. $rawdata=curl_exec ($ch);
  7. curl_close ($ch);
  8. //save image
  9. $fp = fopen("php.gif",'w');
  10. fwrite($fp, $rawdata);
  11. fclose($fp);
  12. ?>