我正在将庞大的csv文件拆分为小块,我可以这样做,但是我希望它下载拆分的部分。我该怎么办
$a=$_FILES['file']['tmp_name'];
$inputFile = $a;
$outputFile = 'splitk';
$splitSize = 50000;
$in = fopen($inputFile, 'r');
$rowCount = 0;
$fileCount = 1;
while (!feof($in)) {
if (($rowCount % $splitSize) == 0) {
if ($rowCount > 0) {
fclose($out);
}
$out = fopen($outputFile . $fileCount++ . '.csv', 'w');
}
$data = fgetcsv($in);
if ($data){
fputcsv($out, $data);}
header('Content-type: text/csv');
header('Content-Disposition: attachment; filename="'.$out.'"');
header("Pragma: no-cache");
header("Expires: 0");
$rowCount++;
}
fclose($out);