title: move and rename file in symfony2
body: <p>I am learning Symfony2, and I am trying to upload an image from a handmade form to a destination folder, but changing its name before.</p>
  
  <p>I think the easiest method is with:</p>
  
  <pre><code>move_uploaded_file(actual_file, destination_with_new_name)
  </code></pre>
  
  <p>But I get the following error message:</p>
  
  <pre><code>ContextErrorException: Warning: move_uploaded_file(http://localhost/PublisherMyAdmin/web/app_dev.php/imagenesportadas/1.jpg): failed to open stream: HTTP wrapper does not support writeable connections in C:\xampp\htdocs\PublisherMyAdmin\src\ochodoscuatro\IntranetBundle\Controller\MaterialesController.php line 163
  </code></pre>
  
  <p>My code is:</p>
  
  <pre><code>$dir =  $this-&gt;getRequest()-&gt;getUriForPath('/imagenesportadas/');
  $nombre = $id.".".$extension;
  
  if (move_uploaded_file($_FILES["archivo"]["tmp_name"], $dir.$nombre)) {
  
      echo "Thank you for uploading your music!&lt;br /&gt;&lt;br /&gt;";
  
  } else {
  
      echo "Your file did not upload.&lt;br /&gt;&lt;br /&gt;";
  
  }
  </code></pre>
  
  <p>Thank you!</p>