1
我使用項目中的OneupUploaderBundle上傳文件。OneupUploaderBundle:在樹枝模板中呈現響應消息
我的問題是:
我怎麼能呈現來自UploadListener的response.msg在我的樹枝模板?我如何評估我的迴應。
https://github.com/1up-lab/OneupUploaderBundle/blob/master/Resources/doc/response.md
//service.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 }
//UploadListener.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({});
我有未找到任何示例...
感謝您的幫助。
謝謝。就是這個方法... – gondor