My PHP version is 5.6.40. I have a variable, in which I want to store an image url.
$imageurl = "http://i132.photobucket.com/albums/q13/animalhelper2006/1376.jpg";
And I'm using file_get_contents
function to get this image.
$contents = file_get_contents($imageurl);
But it does not work, it shows empty result. But when I tried to directly load image url, it worked.
$contents = file_get_contents("http://i132.photobucket.com/albums/q13/animalhelper2006/1376.jpg");
What's wrong? please help.
Thanks
Your problem might come from file name which is included space (" "). You can try using urlencode file name before parsing it into file_get_contents.
Follow @CBroe way. I'm used var_dump and see the length is different. After many checking I found the variable is hex code http://i132.photobucket.com/albums/q13/animalhelper2006/1376.jpg
Final I used html_entity_decode function and it working fine now.
$contents = file_get_contents(html_entity_decode($imageurl));
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.