Skip to content
Advertisement

php write csv to file returns blank file

I have some csv data that looks like this:

JavaScript

When I try to export this csv to a file like this:

JavaScript

I get an empty file, what am I doing wrong here

Advertisement

Answer

From the Symfony docs:

https://symfony.com/doc/current/components/http_foundation.html#request

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.

If that doesn’t fix the issue, maybe try something like this:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement