Symfony2:编辑文件上传 [英] Symfony2: Edit file upload
问题描述
我正在使用symfony.com的食谱文章来实现图像的文件上传选项。
现在我想加载其他图像到实体。 / p>
编辑的默认策略是:
1.取出DB
2.注入表单
3.持久化
不知怎的,这个策略在使用文件上传(doctrine不执行事件)时不起作用。
还有什么
食谱不处理更新特别是在只有文件更改的情况下。
在这种情况下, PreUpdate
事件不会被触发,所以您需要在 $ em-> persist($ entity)$ c $之前手动触发
$ entity-> preUpload()
c>,以便在任何情况下处理文件上传(preUpload将改变 $ entity-> path
,以便持续存在)
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 strategy for editing is: 1. Fetch out of DB 2. Inject into Form 3. Persist
Somehow this strategy doesn't work anymore when using file uploads (doctrine doesn't execute the events)
What else could I do to make the articles with picture editable?
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)
这篇关于Symfony2:编辑文件上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!