我有一个使用 EasyAdminBundle 进行管理的项目。在一个名为"帖子"的实体中,我有"标题","图像"和"帖子"字段,我想跟踪有关更改的信息。属性"image"仅存储图像的文件名 - 完整的上传过程由VichUploaderBundle管理。
如何/在哪里可以网格化旧图像文件不会在更改时被删除,因为它将用于历史记录?
当你定义映射时,有一种方法可以告诉VichUploaderBundle它不应该自动删除旧文件:
以下是从捆绑包文档中获取的示例映射配置:
vich_uploader:
db_driver: orm
mappings:
product_image:
uri_prefix: /images/products
upload_destination: %kernel.root_dir%/../web/images/products
inject_on_load: false
# this prevents the file from being deleted on update
delete_on_update: false
# this prevents the file from being deleted when the
# entity itself is deleted
delete_on_remove: true