Reputation: 173
I have facebook login and signup on my site. I have looked here and there and i am trying to upload image from link.
suppose this is link of image as i wanted to upload image from facebook
http://graph.facebook.com/shaverm/picture?type=large
this will change into
http://m.ak.fbcdn.net/profile.ak/hprofile-ak-ash4/372183_100002526091955_998385602_n.jpg
Now i want it to upload on my site
this image:
http://m.ak.fbcdn.net/profile.ak/hprofile-ak-ash4/372183_100002526091955_998385602_n.jpg
I have found this code here on stackoverflow but i am not sure how this will work out i am trying this from last 2 hours and trying to figure it out but not able to do so i posted here.
$image = @ImageCreateFromString(@file_get_contents($imageURL));
if (is_resource($image) === true){
// image is valid, do your magic here
}else{
// not a valid image, show error
}
This are my code from which i upload picture right now on my site.
if ($_FILES) {
$name = $_FILES['filename']['name'];
$size = $_FILES["filename"]["size"];
switch ($_FILES['filename']['type']) {
case 'image/jpeg':
$ext = 'jpg';
break;
default:
$ext = '';
break;
}
if ($ext) {
if ($size > 800000) {
$imagefalse = '<span id="font">Image is bigger in size sorry!<br / ></span>';
} else {
$path = $imagelink; // old path of image
unlink($path); // remove old file if any
$timestamp = time();
$n = "image/user/$id.$timestamp.$ext";
move_uploaded_file($_FILES['filename']['tmp_name'], $n);
$setnewimage = mysql_query("UPDATE users SET image='$n' WHERE id='$id'");
}
} else
$imagefalse = '<span id="font">File is not an accepted image file<br / ></span>';
}
Upvotes: 0
Views: 196
Reputation: 1
You probably need curl; it is a HTTP (& FTP) client library.
Upvotes: 1