Posted in PHP onJuly 05, 2013
方法一:
header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($filepath)); 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($filepath)); readfile($file_path);
方法二:
$fileinfo = pathinfo($filename); header('Content-type: application/x-'.$fileinfo['extension']); header('Content-Disposition: attachment; filename='.$fileinfo['basename']); header('Content-Length: '.filesize($filename)); readfile($thefile); exit();
解析PHP实现下载文件的两种方法
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@