我在我的项目中使用 OneUploaderBundle 来上传文件。
我的问题是:
如何在我的树枝模板中呈现来自 UploadListener 的 response.msg?我如何评估我的反应。
https://github.com/1up-lab/OneupUploaderBundle/blob/master/Resources/doc/response.md
//服务.yml
acme.upload_listener:
class: Acme\AcmeBundle\EventListener\UploadListener
arguments: ["@doctrine.orm.entity_manager"]
tags:
- { name: kernel.event_listener, event: oneup_uploader.post_persist, method: onUpload }
//上传监听器.php
class UploadListener
{
protected $em;
public function __construct(EntityManager $em)
{
$this->em = $em;
}
public function onUpload(PostPersistEvent $event)
{
$file = $event->getFile();
$session = $event->getRequest()->getSession();
$session->set('file', $file->getPathName());
$response = $event->getResponse();
$response['msg'] = "File stored in session";
=> show response.msg in my twig-template. But how?
}
}
//JS(在树枝模板中)
$('#fileupload').fileupload({});
我没有找到示例...
谢谢你的帮助。