码迷,mamicode.com
首页 > Web开发 > 详细

PHP实现文件下载

时间:2016-06-22 20:16:57      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:

 1 public function get_download_file()
 2 {
 3       header ( ‘Content-Description: File Transfer‘ );
 4       header ( ‘Content-Type: application/octet-stream‘ );
 5       header ( ‘Content-Disposition: attachment; filename=‘ . basename ( $file ));
 6       header ( ‘Content-Transfer-Encoding: binary‘ );
 7       header ( ‘Expires: 0‘ );
 8       header ( ‘Cache-Control: must-revalidate‘ );
 9       header ( ‘Pragma: public‘ );
10       header ( ‘Content-Length: ‘  .  filesize ( $file ));
11       ob_clean ();
12       flush ();
13       readfile ( $file );
14       exit;
15 }

 

PHP实现文件下载

标签:

原文地址:http://www.cnblogs.com/gentsir/p/5608265.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!