public function download_file($file) {
if (file_exists ( $file ))
{
$this_base_file = basename ( $file );
header ( "Content-type:application/octet-stream" );
header ( "Accept-Ranges: bytes" );
header ( "Accept-Length: " . filesize ( $file ) );
header ( "Content-Disposition: attachment; filename=\"" . $this_base_file . "\"" );
readfile ( $file );
}
}
转载于:https://www.cnblogs.com/xlz307/p/3425375.html