用PHP代码下载CSV文件,可以是字符串,也可以是一个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);
$fileName = "pref_" . date("YmdHis") . ".csv"; header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename=' . $fileName); echo $csv;