1 方法一: 2 header('Content-Description: File Transfer'); 3 header('Content-Type: application/octet-stream'); 4 header('Content-Disposition: attachment; filename='.basename($filepath)); 5 header('Content-Transfer-Encoding: binary'); 6 header('Expires: 0′); 7 header('Cache-Control: must-revalidate, post-check=0, pre-check=0′); 8 header('Pragma: public'); 9 header('Content-Length: ' . filesize($filepath)); 10 readfile($file_path); 11 12 方法二: 13 $fileinfo = pathinfo($filename); 14 header('Content-type: application/x-'.$fileinfo['extension']); 15 header('Content-Disposition: attachment; filename='.$fileinfo['basename']); 16 header('Content-Length: '.filesize($filename)); 17 readfile($thefile); 18 exit();