I was trying to output a an image from a controller's private function such
that:
http://host/app/controller/action/
would return an image.
I would need to reset the header's content type but I'm still having problems
(in browser error returned below). I've included some comments on various
things I tried. My code looks like this:
public function somethingAction(){
//ob_start();
$this->_helper->viewRenderer->setNoRender();
$this->_helper->layout->disableLayout();
if($this->_generate('play.html',$data)){
$this->_success();
}else{
$this->_failure();
//echo "failure<br/>";
}
}
private function _success(){
$file_name = "/data/sites/site/www/docs/fadmin/images/ok.gif";
if(ob_get_length()){
ob_end_flush();
exit;
}
/*
$this->_response->setHeader('Content-type', 'image/gif');
$this->_response->setHeader('Cache-Control', 'no-cache');
*/
header('Content-type: image/gif');
header("Cache-control: private, no-cache");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); # Past date
header("Pragma: no-cache");
echo fread(fopen($file_name, 'rb'), filesize($file_name));
/*
ob_end_flush();
$data = file_get_contents($file_name);
$this->_response->setBody($data);
*/
ob_end_flush();
}
The error I get in the browser is:
Any help with this would be greatlly appreciated.
thanks,
jonathan