Reputation: 1167
I am trying to show an image directly in the browser with the help of BinaryFileResponse in a Symfony controller.
On our previous server, this code was working all fine:
$response = new BinaryFileResponse($filePath, 200, [], true, null, true);
$response->headers->addCacheControlDirective('no-cache', true);
$response->headers->addCacheControlDirective('max-age', 0);
$response->headers->addCacheControlDirective('must-revalidate', true);
$response->headers->addCacheControlDirective('no-store', true);
return $response;
But since the migration on the new server, when the $filePath contains an accent (àéè, etc), it forces the image to download instead of just showing it.
Both servers have PHP 7.0.10 installed.
Am I missing a config or something? I can't find why it happens.
Any help is gretaly appreciated. Thank you.
Upvotes: 1
Views: 1155
Reputation: 1167
I found my problem.
Symfony could'nt get the filetype mime in path containing accents. To make it possible, I had to activate PHP extension php_fileinfo in Apache.
Upvotes: 2