您的位置:首页 > 编程语言 > PHP开发

PHP实现文件下载

2016-06-22 19:21 453 查看
public function get_download_file()
{
header ( 'Content-Description: File Transfer' );
header ( 'Content-Type: application/octet-stream' );
header ( 'Content-Disposition: attachment; filename=' . basename ( $file ));
header ( 'Content-Transfer-Encoding: binary' );
header ( 'Expires: 0' );
header ( 'Cache-Control: must-revalidate' );
header ( 'Pragma: public' );
header ( 'Content-Length: '  .  filesize ( $file ));
ob_clean ();
flush ();
readfile ( $file );
exit;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: