Cakephp 2, тип содержимого тела ответа не работает

$this->autoRender = false;
$this->response->header("HTTP/1.1 200 OK");
$this->response->header("Pragma: public");
$this->response->header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
$this->response->header("Cache-Control: private", false);

//$this->response->header("Content-type: image/png"); //tried also
$this->response->type('jpg');

$this->response->body(readfile($file));

return $this->response;

Всегда возвращает Content-Type: text / html; кодировка = UTF-8.

Спасибо

1

Решение

$this->response->body(readfile($file));

Измените эту строку на

$this->response->body(file_get_contents($file));

И работает.

Я знаю, что это более производительный readfile, но на данный момент должен работать.

Вероятно, что-то, что readfile разрывается с окончанием.

0

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector