php读取csv实现csv文件下载功能
程序员文章站
2022-03-29 17:40:49
第一段是读文件,下载。第二段是字符串下载。
复制代码 代码如下:
<?php
$filename = "prefs.csv";
header('content-type: application/octet-stream');
header('content-disposition: attachment; filename=' . $filename);
header('content-transfer-encoding: binary');
header('content-length: ' . filesize($filename));
readfile($filename);
<?php
$filename = "pref_" . date("ymdhis") . ".csv";
header('content-type: application/octet-stream');
header('content-disposition: attachment; filename=' . $filename);
echo $csv;
第一段是读文件,下载。
第二段是字符串下载。
复制代码 代码如下:
<?php
$filename = "prefs.csv";
header('content-type: application/octet-stream');
header('content-disposition: attachment; filename=' . $filename);
header('content-transfer-encoding: binary');
header('content-length: ' . filesize($filename));
readfile($filename);
复制代码 代码如下:
<?php
$filename = "pref_" . date("ymdhis") . ".csv";
header('content-type: application/octet-stream');
header('content-disposition: attachment; filename=' . $filename);
echo $csv;