php下载服务器上的资料
程序员文章站
2024-01-01 13:31:10
...
php下载服务器上的文件
$file_xls=$path; // 文件的保存路径
$example_name=basename($file_xls); //获取文件名
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.mb_convert_encoding($example_name,"gb2312","utf-8")); //转换文件名的编码
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file_xls));
ob_clean();
flush();
readfile($file_xls);
相关文章
相关视频