Zend Framework里怎么实现文件上载功能

WBOY
Release: 2016-06-13 13:25:10
Original
791 people have browsed it

Zend Framework里如何实现文件下载功能
如题,我的目的是想要在一个控制器的方法里实现文件下载
该下载的文件不是本地目录上的文件,而是在控制器的方法里临时的生成的数据文件。
PHP在不用ZF的情况下是可以用设置header信息来让浏览器实现下载的功能,
header("Content-type: text/plain");  
header("Accept-Ranges: bytes");  
header("Content-Disposition: attachment; filename=".$filename);  
header("Cache-Control: must-revalidate, post-check=0, pre-check=0" );  
header("Pragma: no-cache" );  
header("Expires: 0" ); 
就像这样,但是在ZF里我直接拿这段代码放到某个控制器的方法里,比如downloadController的downloadAction()里,同样是这样设置头信息,最后打印数据,
print $data; 
却始终不能实现下载。
请问高手们应该怎么做到在zend framework里实现下载,或者ZF有没有自带的关于文件下载的。看了手册,貌似只有文件上载的。没有下载

------解决方案--------------------
需要禁用layout,viewRenderer
public function downloadAction() { 
$this->_helper->getHelper ( 'layout' )->disableLayout ();
$this->_helper->getHelper ( 'viewRenderer' )->setNoRender (); 

。。。

}

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!