[Form] Upload d'image : Call to a member function move() on a non-object
Bonjour,
J'ai suivi le tuto pour l'upload d'image de la doc Symfony (http://symfony.com/doc/2.0/cookbook/...e_uploads.html) et celui là : http://leny-bernard.com/fr/afficher/...fony2-partie-4
Par contre, lorsque j'upload, je reçois ce message d'erreur :
Fatal error: Call to a member function move() on a non-object in /home/xxxx/public_html/src/Site/MonBundle/Entity/Photo.php on line 209
Voici mon fichier Photo.php : http://pastebin.com/C8MsSHXY
La fonction qui pose problème :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| /**
* @ORM\PrePersist()
* @ORM\PreUpdate()
*/
public function uploadFile() {
// the file property can be empty if the field is not required
if (null === $this->file) {
return;
}
if(!$this->id){
$this->file->move($this->getTmpUploadRootDir(), $this->file->getClientOriginalName());
}else{
$this->file->move($this->getUploadRootDir(), $this->file->getClientOriginalName());
}
$this->setFile($this->file->getClientOriginalName());
} |
Merci pour votre aide
Call to a member function move() on a non-object
Non. J'ai la même erreur et pourtant je ne fais pas appel à la méthode Upload dans le controller.