title: Using file_get_contents vs curl for file size
body: <p>I have a file uploading script running on my server which also features remote uploads.. Everything works fine but I am wondering what is the best way to upload via URL. Right now I am using <code>fopen</code> to get the file from the remote url pasted in the text box named "from". I have heard that fopen isn't the best way to do it. Why is that?</p>
  
  <p>Also I am using file_get_contents to get the file size of the file from the URL. I have heard that <code>curl</code> is better on that part. Why is that and also how can I apply these changes to this script?</p>
  
  <pre><code>&lt;?php
  $from = htmlspecialchars(trim($_POST['from']));
  
  if ($from != "") {
      $file = file_get_contents($from);
      $filesize = strlen($file);
  
      while (!feof($file)) {
          $move = "./uploads/" . $rand2;
          move_upload($_FILES['from']['tmp_name'], $move);
  
          $newfile = fopen("./uploads/" . $rand2, "wb");
          file_put_contents($newfile, $file);
      }
  }
  ?&gt;
  </code></pre>