title: Symfony2: File Upload throws undefined property exception
body: <p>I want to perform an image upload with Symfony2.</p>
  
  <p>I followed the cookbook entry but failed so I firstly used the fallback "upload directly in the controller" but here's the same issue.</p>
  
  <p>I am getting</p>
  
  <pre><code>Notice: Undefined property:  Symfony\Component\Form\Form::$getData in 
  </code></pre>
  
  <p>The controller isValid() part:</p>
  
  <pre><code>            if ($form-&gt;isValid()) {
              $em = $this-&gt;getDoctrine()-&gt;getEntityManager();
  
              $filename = uniqid('class_photo') . '.' . $photo-&gt;getFile()-&gt;guessExtension();
              $directory = __DIR__ . '/../../../../web/';
              $form['file']-&gt;getData-&gt;move($directory, $filename);
              $photo-&gt;setFile(null);
              $photo-&gt;setPath($directory . $filename);
  
              $em-&gt;persist($photo);
              $em-&gt;flush();
  //....
  }
  </code></pre>
  
  <p>Best Regards,
  Bodo</p>