Answer the question
In order to leave comments, you need to log in
Why does the File class error occur when uploading images?
Files are uploaded via ajax in base64.
Saving a file:
if (strlen($this->request->request->get('avatar')) > 100) {
$data = explode(',', $this->request->request->get('avatar'));
$tmp['avatar'] = tmpfile();
$path = stream_get_meta_data($tmp['avatar'])['uri'];
file_put_contents($path, base64_decode($data[1]));
$user->setAvatar(new File($path));
}
//........
if ($user->getAvatar()) {
$name = $this->get('uploader')->moveFile($user->getAvatar(), 'user/a');
$user->setAvatar($name);
}
$em->persist($user);
Serialization of 'Symfony\Component\HttpFoundation\File\File' is not allowed
. Answer the question
In order to leave comments, you need to log in
Well, it’s humanly written to you that you can’t serialize an object of the File class. Look for where your serialization takes place.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question