Hi all,
in my app, I have to retrieve images that are located outside the public directory. Each image is also referenced in a db table (with mime-type, size, access rights and so on)
I want to dispaly them with {{ image("media/image/13" }}
media controller, image action below:
public function image($id)
{
// some stuff to build absolute path to image: $imagePath
// ....
$this->response->setHeader("Content-Type",$image->mime);
$this->response->setHeader("Content-Length",$image->size);
$this->response->setFileToSend($imagePath);
// also tried with:
$response->setHeader("X-Sendfile", $imagePath);
$this->response->send();
}
No image is displayed. Content-Length is not the right one ... What am I doing wrong ? Any help really appreciated !
response headers with setFileToSend:
Connection:Keep-Alive Content-Description:File Transfer Content-Disposition:attachment; filename=22.jpg Content-Length:465 Content-Transfer-Encoding:binary Content-Type:image/jpeg
response headers with X-Sendfile:
Connection:Keep-Alive Content-Length:45 Content-Type:image/jpeg Date:Sun, 08 Dec 2013 20:34:06 GMT Keep-Alive:timeout=5, max=98 Server:Apache/2.2.22 (Debian) X-Powered-By:PHP/5.4.4-14+deb7u5 X-Sendfile:/var/www/phalcon/medias/app/files/2013-12-08/22.jpg