I'm trying to save images in database with forms and Doctrine. In my entity, I've done this:
/**
* @ORM\Column(name="photo", type="blob", nullable=true)
*/
private $photo;
private $file;
/**
* @ORM\PrePersist()
* @ORM\PreUpdate()
*/
public function upload()
{
if (null === $this->file) {
return;
}
$this->setPhoto(file_get_contents($this->getFile()));
}
And I've also added this in my form type:
->add('file', 'file')
But I'm getting this error when I upload a file:
Serialization of 'Symfony\Component\HttpFoundation\File\UploadedFile' is not allowed