I would like to create a csv file with the data that I get by querying the database. Then the browser should ask the user to download the file. The problem is that the readfile function requires a file name, not a descriptor, but I cannot find a function to get the file name of this temporary file. I think there are better ways to do this, but I cannot find them.
$handle = tmpfile(); fputcsv($handle, array('year', 'month', 'product', 'count')); header('Content-Type: application/csv'); header('Content-Disposition:attachment;filename=LS_export'); echo readfile($handle); fclose($handle); exit();
Riesling
source share