Загрузка файлов происходит через ajax в base64.
Сохранение файла:
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
.
Что я делаю не так?