欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

PHP实现文件下载,_PHP教程

程序员文章站 2022-05-04 20:13:01
...

PHP实现文件下载,

 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 }

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1136182.htmlTechArticlePHP实现文件下载, 1 public function get_download_file() 2 { 3 header ( 'Content-Description: File Transfer' ); 4 header ( 'Content-Type: application/octet-stream' ); 5 heade...