title: Uploaded an image using `file_put_contents` with 0 bytes (empty)?
body: <p>I've downloaded an image using <code>file_get_contents</code> from URL then uploaded it to my website using <code>file_put_contents</code>, the image appears in the specified directory, however it has the size of zero. I've changed the permissions to 777 in this directory and the parent directories, but nothing happened.</p>
  
  <p>I already tried the same code in the localhost, and it worked perfectly.</p>
  
  <p>By the way, I'm using a joomla website and a component called RSform Pro, it is used for creating forms and gives an area where you can edit the POST data before saving it in the database. Here's the code.</p>
  
  <pre><code>$content = file_get_contents($_POST['image_url']);
  
  $date = date ('d-m-Y_h-m-i');   $random = rand(0,1000);
  $name = 'mysite_'.$date.$random.'.png';
  
  $filename = '/home/mysite/images/'.$name;
  
  file_put_contents($filename, $content);
  </code></pre>