uploading an image with file_put_contents makes 0 byte file.
here is the code that I use. I extract facebook image url and put it into the web server.
$fb_image_url = 'https://example.com/229282.jpg'
$filename = substr($fb_image_url, strrpos($fb_image_url, '/') + 1);
file_put_contents('upload/user_pic/original/'.$filename, file_get_contents($fb_image_url));
after I do this, the server receives the file name successfully, but it is 0 bytes.
I checked php.ini, and allow_url_fopen is ON.
uploading folder permission is also fine.
To copy images from facebook, script/php program requires permission for the same. if the program/ FB API doesn’t pass the validation/permission check, FB doesn’t allow downloading of any image.
It looks like your Application doesn’t have permission to download/copy this image from Facebook that’s why you’re getting 0 bytes.
Try giving PUBLIC access to images and keep FB account logged in while coping image