我已閱讀線程output image in a Kohana 3.2 view,但代碼無法在我的電腦上運行。Kohana 3.2.0無法正確輸出圖像
我寫輸出到瀏覽器 圖像的動作(如果我改變了超類控制器,它仍然無法正常工作。),代碼如下:
class Controller_Portal extends Controller_Template {
public function action_view() {
$filename = "E:\workspace\myphoto.jpg";
$this->response->headers('Content-Type', File::mime($filename))
->send_headers() // If I remove this line, It still doesn't work
->body(file_get_contents($filename));
exit;
}
}
你好,我試圖刪除 - > send_headers(),該動作仍然不起作用。 –
夠公平的。我能夠建議的唯一其他事情就是快速回顯'File :: mime($ filename)'以確保它確實獲得正確的文件。除此之外,對於更熟悉Ko3.2的任何人 - 我使用3.0和2.3 – Joe