Posted By

multani on 04/21/08


Tagged

curl php download img


Versions (?)

Who likes this?

6 people have marked this snippet as a favorite

koncept
jamesming
rinx
qubestream
wirenaught
tux-world


PHP CURL IMG DOWNLOAD


 / Published in: PHP
 

URL: http://blog.roodo.com/rocksaying/archives/2102451.html

  1. function SaveCurlPage ($url, $save_file) {
  2. $ch = curl_init($url);
  3. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  4. curl_setopt($ch, CURLOPT_REFERER, $url); // need to fake a referer
  5. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  6. curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
  7. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  8. curl_setopt($ch, CURLOPT_COOKIEJAR, "curl_cookie");
  9. curl_setopt($ch, CURLOPT_COOKIEFILE, "curl_cookie");
  10. $tmp = curl_exec ($ch);
  11. if(curl_errno($ch) == 0) {
  12. file_put_contents($save_file, $tmp);
  13. }
  14. curl_close ($ch);
  15.  
  16. return curl_errno($ch);
  17. }

Report this snippet  

You need to login to post a comment.