* Download File
*
* @param string $downloadFile
* @param string $downloadName
*/
Private Function DownLoad ($downloadFile, $downloadName) {
Header ("Cache-control:public");
Header ("Content-description:file Transfer");
Header (' content-disposition:attachment; Filename= '. $downloadName); Filename
Header ("Content-type:application/zip"); In the ZIP format
Header ("Content-transfer-encoding:binary"); Tell the browser that this is a binary file
Header (' Content-length: '. FileSize ($downloadFile)); Tell the browser, file size
@readfile ($downloadFile);
}
------------------------------------------------------------------------------------
/**
* Customer Credit Application Attachment download
*/
Public Function attachmentdownloadaction () {
$request = $this->getrequest ();
$filePath = $request->getparam (' FilePath ');
$filePath = zend_filter::filterstatic ($filePath, ' Stringtrim ');
$filePath = zend_filter::filterstatic ($filePath, ' striptags ');
$filePath = Application_path. " /.. /public ". $filePath;
$fileName = $request->getparam (' fileName ');
$fileName = zend_filter::filterstatic ($fileName, ' Stringtrim ');
$fileName = zend_filter::filterstatic ($fileName, ' striptags ');
$fileName = Iconv ("UTF-8", "GB2312", $fileName);
if (file_exists ($filePath)) {
$this->attachmentdownload ($filePath, $fileName);
} else {
throw new Member_model_notexist_exception (' attachment does not exist! ‘);
}
}
Private Function Attachmentdownload ($filePath, $fileName)
{
$file = file_get_contents ($filePath);
$this->getresponse ()
->setbody ($file)
->setheader (' Content-type ', ' Application/octet-stream ')
->setheader (' Content-disposition ',
' Attachment; Filename= "'. $fileName. ')
->setheader (' Content-length ', strlen ($file));
$this->_helper->layout->disablelayout ();
$this->_helper->viewrenderer->setnorender (TRUE);
Header (' set-cookie:filedownload=true; path=/');
$this->getresponse ()->sendresponse ();
}