Answer the question
In order to leave comments, you need to log in
How to upload a file using JMS Serializer?
I'm developing a REST API using Symfony 4. How to upload a file using JMS Serializer? Now outputs: Notice: Array to string conversion
App\Entity\Answer
/**
* @Type("string")
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $file;
$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();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question