方法一:
复制代码代码如下:
header('Content-Description: 文件传输');
header('内容类型:application/octet-stream');
header('内容处置:附件; filename='.basename($filepath));
header('内容传输编码:二进制');
header('过期:0′);
header('缓存控制:必须重新验证,后检查=0,预检查=0′);
header('Pragma: public');
header('内容长度: ' .filesize($filepath));
readfile($file_path);
复制代码代码如下:
$fileinfo = pathinfo($filename);
header('内容类型:application/x-'.$fileinfo['extension']);
header('Content-Disposition:attachment; filename='.$fileinfo['basename']);
header('内容长度:'.filesize($filename));
readfile($thefile);
exit();