PHP CURL IMG DOWNLOAD


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your 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. }

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.