所以我有两个文件,一个读取现有的CSV编辑并更改一些值,然后写入一个新文件。我的目标是可以直接下载新的csv。它可以在两个单独的文件中工作,但我必须将它们组合在一起……它不起作用。
´
如果我将两个分开,那么它确实可以工作,但是当我像这样将它们组合在一起时,它就行不通了:
$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');
?>