How to save/copy Facebook image URL to my SERVER as an image?

850 Views Asked by At

This is the url: https://scontent.xx.fbcdn.net/v/t34.0-12/15749870_10153984148031541_865898377_n.jpg?_nc_ad=z-m&oh=73dc146bd7d8922a41c262ecc2299bb4&oe=58659947

I want to save Facebook images to my server. I tried many options such as copy, file_get_contents etc. What happens is that i get a blank image file that has 0 file size.

How do i save/copy facebook image url to my server as an image?

1

There are 1 best solutions below

2
On

Try:

$url = "https://scontent.xx.fbcdn.net/v/t34.0-12/15749870_10153984148031541_865898377_n.jpg?_nc_ad=z-m&oh=73dc146bd7d8922a41c262ecc2299bb4&oe=58659947";

$img = './your_image_name.jpg';
file_put_contents($img, file_get_contents($url));