Very useful Php curl script to download save live url image to website or local system folder.
Example : 1
<?php
$uid = "Fb user account ID";
$headers = get_headers('http://graph.facebook.com/'.$uid.'/picture?type=large',1);
$profileimage = $headers['Location']; //fb user image URL
$ch = curl_init($profileimage);
$fp = fopen('images/user/user.gif', 'wb');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
?>
Example : 2
<?php
function save_image($img, $fullpath) {
$ch = curl_init ($img);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
$binary_img = curl_exec($ch);
curl_close ($ch);
if (file_exists($fullpath)){
echo "File Already Exist";
unlink($fullpath);
}
else
{ echo "File Added Sucessfully";
$fp = fopen($fullpath, 'x');
fwrite($fp, $binary_img);
fclose($fp);
}
}
?>
Example : 3
<?php
$uid = "Fb user account ID";
$headers = get_headers('http://graph.facebook.com/'.$uid.'/picture?type=large',1);
$profileimage = $headers['Location']; //fb user image URL
function save_image($inPath,$outPath)
{ //Download images from remote server
$in= fopen($inPath, "rb");
$out= fopen($outPath, "wb");
while ($chunk = fread($in,8192))
{
fwrite($out, $chunk, 8192);
}
fclose($in);
fclose($out);
}
save_image($profileimage,'images/user/'.$userdata['user_id'].'.gif');
?>
Whom help my get Facebook user profile picture | Store image from url to website using curl article ?
- Developer who looking a Php script to download / save image from Url to Pc using curl
- Save Facebook user profile picture
- Download live url image to local system folder
- Save Online site image using Curl php Script
- Developed login with Facebook Ac functionality and want to store user profile picture on login than its you need it

0 Comments