/**
* Sends a file to the browser
*
* @param string $fileName
* @param string $directory
*/
public function sendFile($newFileName, $originalFilePath)
{
$this->setRenderNavMenu(false);
$this->setRenderLayout(false);
$this->setRenderView(false);
$this->getResponse()
->clearAllHeaders()
->setHeader("Pragma", "public", true)
->setHeader('Cache-control', 'must-revalidate, post-check=0, pre-check=0', true)
->setHeader('Cache-control', 'private')
->setHeader('Expires', '0', true)
->setHeader('Content-Type', 'application/octet-stream')
->setHeader('Content-Transfer-Encoding', 'binary', true)
->setHeader('Content-Length', filesize($originalFilePath), true)
->setHeader('Content-Disposition', 'attachment; filename=' . $newFileName)
->setBody(file_get_contents($originalFilePath));
}
Ed Lazor wrote:
Hi Tom, Good to hear from you. Ironically, I'd found your sendfile helper and was using it when I ran into the problem with IE. I'll send you a copy of what I ended up with for now. -Ed On Thu, May 21, 2009 at 2:52 AM, Tom Graham<tom.graham@jadu.co.uk> wrote:I wrote a post on blog about this not so long ago: http://www.noginn.com/2009/03/08/sending-files-with-the-zend-framework/ I created a simple action helper to make sending files for download easy. Hope it can be of some use to you. Tom
没有评论:
发表评论