对不起,如果标题没有解释.让我试着进一步解释.
我的代码看起来像这样:
<?
//Grab the number in count.txt
$count = intval(file_get_contents('count.txt'));
//Move the number up one
file_put_contents('count.txt', ++$count);
$number = file_get_contents('count.txt');
//Force Download
header('Content-Disposition: attachment; filename=DataFiles'.$number.".csv");
header('Content-Type: application/octet-stream');
//The data
foreach($array as $info){
echo $info."\n";
}
?>
Run Code Online (Sandbox Code Playgroud)
$ array是一个数组.
现在有时数据量可能超过5000,因此如果数据超过5000,则为每个回显的5000个数据创建另一个文件.Ea:如果$ array中有20,000个数据,那么它将总共生成4个文件.
小智 10
在这里,您将了解如何下载多个文件...这些技巧在同一页面中渲染了许多iframe.每个帧都有不同的源,强制下载不同的文件
<?php
for($i = 0; $i<5; $i++){
echo '<iframe src="test_multiple_downfile.php?text='.$i.'">/iframe>';
}
?>
Run Code Online (Sandbox Code Playgroud)
test_multiple_downfile.php的内容是这样的:
$out = $_GET['text'];
header("Content-Type: plain/text");
header("Content-Disposition: Attachment; filename=testfile_".$out.".txt");
header("Pragma: no-cache");
echo "$out";
Run Code Online (Sandbox Code Playgroud)