<?php
header ( 'Content-Description: File Transfer' );

header ( 'Content-Type: application/octet-stream' );

header ( 'Content-Disposition: attachment; filename=' .$filename);

header ( 'Content-Transfer-Encoding: binary' );

header ( 'Expires: 0' );

header ( 'Cache-Control: must-revalidate' );

header ( 'Pragma: public' );

header ( 'Content-Length: ' . filesize ( $file ));
readfile($filename);

原生php文件下载功能_后端