PHP实现文件下载,_PHP教程

WBOY
發布: 2016-07-12 08:49:52
原創
836 人瀏覽過

PHP实现文件下载,

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

 

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...
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板