Rumah > Artikel > pembangunan bahagian belakang > php下载服务器上的资料
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);