0
我的项目实际上是建立一个网站,允许我发布GIF,JPG等。Vichuploader文件不保存与POST请求
我使用VichuploaderBundler上传文件并将其保存到特定的资源库在我的应用程序
#vich uploader Configuration vich_uploader: db_driver: orm mappings: product_image: uri_prefix: /images/posts upload_destination: '%kernel.root_dir%/../web/images/posts' namer: vich_uploader.namer_uniqid inject_on_load: false delete_on_update: true delete_on_remove: true
我创建了一个API来创建和渲染ressources。
我正在尝试创建一个帖子,提供邮递员的邮寄请求。 在这篇文章中,我想保存一个图像扔vichuploader。(这曾经与一个古典形式)。
这里是我的问题:
我的职位是创建THX我邮递员请求。但是,我上传的文件不会被保存在
/**
* @Rest\View(statusCode=Response::HTTP_CREATED)
* @Rest\Post("/posts")
*/
public function postPostsAction(Request $request)
{
$post = new Post();
$post->setTitle($request->get('title'))
->setDescription($request->get('description'))
->setImageName($request->get('image_name'))
->setImageFile($request->get('imageFile'))
// It is required that at least one field changes if you are using doctrine
// otherwise the event listeners won't be called and the file is lost
->setUpdatedAt(new \DateTime());
$em = $this->get('doctrine.orm.entity_manager');
$em->persist($post);
$em->flush();
return $post;
}
THX帮助和反馈有关我的文章。