|
@@ -613,13 +613,29 @@ function excelSave($fileName = '', $headArr = [], $data = [])
|
|
|
header('Content-disposition: attachment; filename=' . basename($file_dir)); # 处理文件名
|
|
|
header("Content-Type: application/octet-stream"); # 流文件输出
|
|
|
header("Content-Transfer-Encoding: binary"); # 告诉浏览器,这是二进制文件
|
|
|
- header('Content-Length: ' . filesize($file_dir)); # 告诉浏览器,文件大小
|
|
|
- readfile($file_dir); # 输出文件
|
|
|
+// header('Content-Length: ' . filesize($file_dir)); # 告诉浏览器,文件大小
|
|
|
+// readfile($file_dir); # 输出文件
|
|
|
+ $res = read_big_file($file_dir);
|
|
|
+ foreach ($res as $val) {
|
|
|
+ echo $val;
|
|
|
+ }
|
|
|
@ unlink($file_dir);
|
|
|
exit();
|
|
|
}
|
|
|
|
|
|
-function deldir($path){
|
|
|
+//读取大文件
|
|
|
+if (!function_exists('read_big_file')){
|
|
|
+ function read_big_file(string $file=''){
|
|
|
+ $handle = fopen($file, 'rb');
|
|
|
+ while (feof($handle) === false) {
|
|
|
+ yield fgets($handle);
|
|
|
+ }
|
|
|
+ fclose($handle);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+ function deldir($path){
|
|
|
//如果是目录则继续
|
|
|
if(is_dir($path)){
|
|
|
//扫描一个文件夹内的所有文件夹和文件并返回数组
|