$filename = $file; //文件路径
$mime = 'application/force-download';
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private',false);
header('Content-Type: '.$mime);
header('Content-Disposition: attachment; filename="'.basename($filename).'"');
header('Content-Transfer-Encoding: binary');
header('Connection: close');
readfile($filename);
exit();
PHP 下载txt文件 功能
最新推荐文章于 2021-03-09 21:03:31 发布