I have to download a png file and use it for Image Processing in php. I want to save this image: /favicon?domain=http://facebook.com/">https://plus.google.com//favicon?domain=http://facebook.com/ into my local folder and perform image processing operations over it.
When I am doing this, its working fine:
$url = 'http://s.wordpress.org/about/images/color-blue.png';
$img = 'try1.png';
file_put_contents($img, file_get_contents($url));
but this is not working a file try1.png is getting created of 0kb
$url = "https://plus.google.com/_/favicon?domain=http://facebook.com/";
$img = 'try1.png';
file_put_contents($img, file_get_contents($url));
Please help. Regards, Suyash
Please try this:
<?php
$url = "https://plus.google.com/_/favicon?domain=http://facebook.com/";
$img = 'try1.png';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
file_put_contents($img, $result);
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.