Symfony2: Edit file upload

后端 未结 3 1638
慢半拍i
慢半拍i 2021-02-04 18:35

I am using the cookbook article from symfony.com to implement a file upload option for images.

Now I want to load up other images to the entity.

The default stra

3条回答
  •  梦毁少年i
    2021-02-04 19:27

    The cookbook does not handle updates, in particular in the case where only the file changes.

    In this case, the PreUpdate event is not triggered, so you need to trigger $entity->preUpload() manually before the $em->persist($entity), so that the file upload gets handled in any case (preUpload will alter $entity->path so the persisting will occur)

提交回复
热议问题