I\'m trying to create a short PHP script that takes a JSON string, converts it to CSV format (using fputcsv), and makes that CSV available as a downloaded .csv file
fputcsv
One problem is that tmpfile() returns a file handle, while filesize takes a filename as parameter. The following line:
header('Content-Length: ' . filesize($tmp));
probably gets evaluated as:
header('Content-Length: 0');
Check that all the calls to header() are executed before any output happens.