So i have two files one reads an exsisting CSV edits and changes some values and then writes a new file. My goal is it that the new csv is then directly downloadable. It works in two seperate files but i have to combine them... it does not work.
´
If i have the two seperate it does work but when i combined them like this it did not work:
$file_name = 'sample.csv';
$fp = fopen($file_name, 'w');
foreach ($infos as $info) {
fputcsv($fp,explode(';',$info));
}
fclose($fp);
header('Content-type: application/csv');
header('Content-Disposition: attachment; filename=sample.csv');
readfile('sample.csv');
//FIRST FILE (JUST THE LAST BIT WHERE THE FILE IS CREATED)
$file_name = 'sample.csv';
$fp = fopen($file_name, 'w');
foreach ($infos as $info) {
fputcsv($fp,explode(';',$info));
}
fclose($fp);
echo "<script>window.open('.../Leon/downloadFile.php')</script>";
?>
//SECOND FILE AT (.../Leon/downloadFile.php)
<?php
header('Content-type: application/csv');
header('Content-Disposition: attachment; filename=sample.csv');
readfile('sample.csv');
?>