PHP, uploading image with file_put_contents make 0 byte file
<p>uploading image with file_put_contents make 0 byte file.</p>

<p>here is the code that I use. I extract facebook image url and put it into web server.</p>

<pre><code>$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));
</code></pre>

<p>after I do this, the server receive file name successfully, but it is 0 bytes.</p>

<p>I checked php.ini, and allow_url_fopen is ON.</p>

<p>uploading folder permission is also fine.</p>
