I have some images in "app/var/assets" (I have to put these images in that directory, I can't change this by client restriction).
I need to show these images. App directory is not an accesible path for Apache, so I need to use X-Send File.
How can I use X-Send File for this?
I tried in my controller:
$path = $this->get('kernel')->getRootDir() . '/var/assets/example.jpg';
$response = new BinaryFileResponse($path');
$response->trustXSendfileTypeHeader();
$response->headers->set('Content-type', 'image/jpg');
$response->sendHeaders();
$response->setContentDisposition(ResponseHeaderBag::DISPOSITION_INLINE, "name");
And then in my view:
<img src="<?= $response ?>" />
But the image is not found and the url I get for the image is:
HTTP/1.0 200 OKCache-Control: publicContent-Disposition: inline; filename=
Any idea?