抱歉,如果标题没有解释太多。让我尝试进一步解释。
我的代码如下所示:
<?
//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";
}
?>
$array 是一个数据数组。
现在有时数据量可能会超过5000,因此如果数据超过5000,则为每5000个正在回显的数据创建另一个文件。 ea:如果$array中有20000条数据,那么总共会生成4个文件。
这是下载多个文件的方法...
技巧是在同一页面中渲染多个 iframe。
每个框架都有不同的源,强制下载不同的文件
<?php
for($i = 0; $i<5; $i++){
echo '<iframe src="test_multiple_downfile.php?text='.$i.'">/iframe>';
}
?>
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";
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)