title: Symfony - File uploads in form - file is not moving over from the tmp directory
body: <p>Can someone point out what I'm missing here? I'm currently adding in file uploads into a form yet the file does not move over from the tmp directory. I'm not getting any errors but the image does not copy over and is residing in the tmp directory. I've tried setting permissions to the file folders where the images will reside and tinkering with the getUploadDir() path but still no luck.</p>
  
  <p>The web/bundles/bloggerblog is symlinked. I think the problem lies in the path I am using in the getUploadDir, do I use the path from (src/blogger/blogbundle/Resources/public/images) so it's symlinked or use the (web/bundles/bloggerblog/images) folder?</p>
  
  <p>Current code:</p>
  
  <p><strong>entity</strong></p>
  
  <pre><code>protected $file;
  
  public function getUploadDir()
  {
  
      return '/bundles/bloggerblog/images';
  
  }
  
  public function getUploadRootDir()
  {
      return __DIR__.'/../../../../web/'.$this-&gt;getUploadDir();
  }
  
  public function getWebPath()
  {
      return null === $this-&gt;image ? null : $this-&gt;getUploadDir().'/'.$this-&gt;image;
  }
  
  public function getAbsolutePath()
  {
      return null === $this-&gt;image ? null : $this-&gt;getUploadRootDir().'/'.$this-&gt;image;
  }
  
  /**
   * @ORM\PrePersist()
   * @ORM\PreUpdate()
   */
  public function preUpload()
  {
      if (null !== $this-&gt;file) {
          // Generate a unique name
          $this-&gt;image = uniqid().'.'.$this-&gt;file-&gt;guessExtension();
      }
  }
  
  /**
   * @ORM\PostPersist()
   * @ORM\PostUpdate()
   */
  public function upload()
  {
      if (null === $this-&gt;file) {
          return;
      }
  
      // If there is an error when removing the file, an exception will be automatically thrown by move().
      // This will properly prevent the entity from being persisted to the database on error.
      $this-&gt;file-&gt;move($this-&gt;getUploadRootDir(), $this-&gt;image);
  
      unset($this-&gt;file);
  }
  
  /**
   * @ORM\PostRemove()
   */
  public function removeUpload()
  {
      if ($file = $this-&gt;getAbsolutePath()) {
          unlink($file);
      }
  }
  </code></pre>
  
  <p><strong>controller</strong></p>
  
  <pre><code>public function createAction(Request $request)
  {
      $blog = new Blog();
  
      $form = $this-&gt;createFormBuilder($blog)
          -&gt;add('title', 'text')
          -&gt;add('author', 'text')
          -&gt;add('blog', 'textarea')
          -&gt;add('image', 'file')
          -&gt;add('tags', 'text')
          -&gt;add('save', 'submit')
          -&gt;getForm();
  
      $form-&gt;handleRequest($request);
      if ($form-&gt;isValid()) {
          $em = $this-&gt;getDoctrine()
              -&gt;getManager();
          $em-&gt;persist($blog);
          $em-&gt;flush();
  
          // return new Response('Blog was added successfully');
          return $this-&gt;redirect($this-&gt;generateUrl('BloggerBlogBundle_homepage'));
      }
  
      $build['form'] = $form-&gt;createView();
  
      return $this-&gt;render('BloggerBlogBundle:Blog:create.html.twig', $build);
  }
  </code></pre>
  
  <p><strong>createform</strong></p>
  
  <pre><code>{% extends 'BloggerBlogBundle::layout.html.twig' %}
  
  {% block title %}Add Blog{% endblock %}
  
  {% block body %}
  &lt;h1&gt;Add Blog&lt;/h1&gt;
  {% include 'BloggerBlogBundle:Blog:form.html.twig' with { 'form': form } %}
  {% endblock %}
  </code></pre>
  
  <p><strong>form</strong></p>
  
  <pre><code>&lt;form action="{{ path('BloggerBlogBundle_blog_create') }}" method="post" {{ form_enctype(form) }} class="blogger"&gt;
  {{ form_widget(form) }}
  </code></pre>
  
  <p></p>