首页 > Web开发 > 详细

PHP实现文件下载

时间:2016-06-22 20:16:03      阅读:360      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!