【发布时间】:2012-06-25 08:56:26
【问题描述】:
我正在尝试在 Zend Framework PHP 应用程序中向浏览器发送文件。我在这里找到了一个动作助手 - https://github.com/noginn/noginn/blob/master/Noginn/Controller/Action/Helper/SendFile.php
在我的控制器中,我有这样的操作
public function downloadfileAction()
{
//get the file name and strip out all white spaces
$title = preg_replace('/\s+/', '', $this->getRequest()->getParam('title'));
//create the file path
$path = 'downloads/'.$title.'.pdf';
//call the action helper to send the file to the browser
$this->_helper->SendFile->sendFile($path, 'application/x-pdf');
}
我的文件位于我的公共文件夹中,即 MyApp/public/downloads/myFile.pdf
当我运行该操作时,我得到一个未找到视图文件的错误并且没有开始下载。
exception 'Zend_View_Exception' with message 'script 'myController/downloadfile.phtml' not found ...
谁能建议我做错了什么?
【问题讨论】:
标签: php zend-framework