Hi, I should set up a simple download manager and I don't understand whay this code doesn't work:
protected function doDownload($filename){
//$this->_helper->layout()->disableLayout();
//$this->_helper->viewRenderer->setNoRender(true);
$dir = Zend_Registry::get('dir');
$file = $dir->assets.$filename;
if(file_exists($file)){
$response = $this->getResponse();
$response->setHeader('Content-Description','File Transfer', true);
$response->setHeader('Content-Type','application/octet-stream', true);
$response->setHeader('Content-Disposition','attachment; filename='.basename($file), true);
$response->setHeader('Content-Transfer-Encoding','binary', true);
$response->setHeader('Expires','0', true);
$response->setHeader('Cache-Control','must-revalidate, post-check=0, pre-check=0', true);
$response->setHeader('Pragma','public', true);
$response->setHeader('Content-Length: ' , filesize($file),true);
ob_clean();
flush();
readfile($file);
exit(0);
/*header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit(0);*/
}
}
while with the commented code the script works fine.
Can you help me please ?
Bye.