Skip to content

Empty file sent to the browser when using BinaryFileResponse🔗

tl;dr: add clearstatcache(true, $file); before sending the file to the browser.

If you just created the file during this same request, the file may be sent without any content. This may be due to cached file stats that return zero for the size of the file. To fix this issue, call clearstatcache(true, $file) with the path to the binary file. source: https://symfony.com/doc/current/components/http_foundation.html#serving-files

Project references🔗


Last update: December 20, 2024