Symfony JMS序列化器-上载文件的端点

时间:2019-07-09 20:39:07

标签: symfony doctrine-orm jms symfony4 jms-serializer

如何使用JMS序列化程序上载文件?现在我得到Notice: Array to string conversion

App \ Entity \ Answer

/**
 * @Type("string")
 * @ORM\Column(type="string", length=255, nullable=true)
 */
private $file;

App \ Controller \ AnswerController

$data = array_replace_recursive(
    $request->request->all(),
    $request->files->all()
);

$serializer = SerializerBuilder::create()->build();
$object = $serializer->deserialize(json_encode($data), Answer::class, 'json');

$em = $this->getDoctrine()->getManager();
$em->persist($object);
$em->flush();

0 个答案:

没有答案