Dear Kirby community,
for a Kirby 3 site, I use this router to export some registration data as CSV file.
[
'pattern' => 'api/csv',
'action' => function() {
header::download(['mime'=>'application/csv', 'name' => 'regs.csv', 'Pragma' => 'no-cache', 'Content-Disposition' => 'attachment']);
$regs = site()->index()->find('register/anmeldestatus')->anmeldungen()->yaml();
$f = fopen('php://output', 'w');
foreach($regs as $registration) {
fputcsv($f, $registration, ';','"');
}
fpassthru($f);
return false;
}
]
]
The file download works, the CSV file is well formed, but in the last line it contains the words “Not found” or the HTML of an error page, when there is one.
Any idea here on the forum?
Many thanks in advance