php读取csv实现csv文件下载功能_php实例
程序员文章站
2024-02-16 09:18:04
...
第一段是读文件,下载。
第二段是字符串下载。
$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);
$fileName = "pref_" . date("YmdHis") . ".csv";
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . $fileName);
echo $csv;
第二段是字符串下载。
复制代码 代码如下:
$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);
复制代码 代码如下:
$fileName = "pref_" . date("YmdHis") . ".csv";
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . $fileName);
echo $csv;
上一篇: 功能控制完备的PHP上载程序(2)
下一篇: 怎么对PHP文件进行加密