我使用zend框架2並嘗試返回一個創建與gd2庫jpeg圖像。但它不起作用。你能看看我的代碼有什麼問題嗎?我的代碼通常在普通的php中運行,但在zf2的問題?返回動態圖像zf2
class PictureController extends AbstractActionController
{
public function colorPaletteAction(){
....
....
//canvas created at above.
imagejpeg($canvas);
imagedestroy($canvas);
$response = $this->getResponse();
return $response->getHeaders()->addHeaderLine('Content-Type', 'image/jpeg');
}
}
是否禁用了未顯示的代碼中的佈局和視圖? –
是的,我試過這個,但它doeesn't工作:( – Yargicx
$ response = $ this-> getResponse(); $ response-> getHeaders() - > addHeaderLine('Content-Type','image/JPEG'); $視圖模型=新的視圖模型(); $ viewModel-> setTerminal(真); 回報$視圖模型; – Yargicx