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