title: Import file from url instead of upload
body: <p>I've used <a href="http://symfony.com/doc/current/cookbook/doctrine/file_uploads.html" rel="nofollow">file upload example</a> to add files to an entity. Now I'm trying to import the existent files from the previous project (in WordPress). I've wrote a script that imports the current database in Symfony2.</p>
  
  <p>All is going well, except for the file uploads. I want to rename the files (<a href="http://symfony.com/doc/current/cookbook/doctrine/file_uploads.html#using-the-id-as-the-filename" rel="nofollow">using the id as the filename</a>). The example uses a request to handle the form, but since I'm using a current database to get the data, there isn't a request.</p>
  
  <p>I've tried this:</p>
  
  <pre><code>$old_image = '../../../public_html/uploads/images/'.$filename;
  
  $file = new UploadedFile($old_image, '337-1.jpg');
  
  $img = new Entity\Image();
  $img-&gt;setFile($file);
  
  $this-&gt;em-&gt;persist($img);
  </code></pre>
  
  <p>I'm getting this error:</p>
  
  <p><code>The file "337-1.jpg" was not uploaded due to an unknown error.</code> </p>
  
  <p>How can I set a file without using a form (and request)?</p>