All pastes #958717 Raw Edit

Untitled

public text v1 · immutable
#958717 ·published 2008-03-26 21:56 UTC
rendered paste body
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;
	}
}