class ImagesController extends Zend_Controller_Action { public function viewAction() { $this->_helper->viewRenderer->setNoRender(); $type = $this->_request->getParam('type', ''); $id = (int)$this->_request->getParam('id', 0); if (empty($type) || empty($id)) { // Do some kind of error thing here. } switch ($type) { case 'icons': $icons = new Icons; $row = $icons->fetchRow('id='.$id); break; default: throw new Exception('Bad url.'); } header("Content-Type: ".$row->mime); header("Content-Disposition: inline; filename=test.jpg"); echo $row->file; } }