首页建站经验 php文件下载函数

php文件下载函数

/*** 文件下载* @param $filepath 文件路径* @param $filename 文件名称*/function file_down($filepath, $filename = '') {if(!$filename) $filename = basename($filepat…

/**

* 文件下载

* @param $filepath 文件路径

* @param $filename 文件名称

*/

function file_down($filepath, $filename = '') {

if(!$filename) $filename = basename($filepath);

if(is_ie()) $filename = rawurlencode($filename);

$filetype = fileext($filename);

$filesize = sprintf("%u", filesize($filepath));

if(ob_get_length() !== false) @ob_end_clean();

header('Pragma: public');

header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');

header('Cache-Control: no-store, no-cache, must-revalidate');

header('Cache-Control: pre-check=0, post-check=0, max-age=0');

header('Content-Transfer-Encoding: binary');

header('Content-Encoding: none');

header('Content-type: '.$filetype);

header('Content-Disposition: attachment; filename="'.$filename.'"');

header('Content-length: '.$filesize);

readfile($filepath);

exit;

}

 

本文来自网络,不代表1号站长-站长学院|资讯交流平台立场。转载请注明出处: https://www.1cn.cc/jianzhan/jingyan/17161.html
上一篇php字符截取函数支持UTF8与GBK
下一篇 PageAdmin CMS工作流及信息签发功能的使用
admin

作者: admin

这里可以再内容模板定义一些文字和说明,也可以调用对应作者的简介!或者做一些网站的描述之类的文字或者HTML!

为您推荐

评论列表()

    联系我们

    联系我们

    0898-88888888

    在线咨询: QQ交谈

    邮箱: email@wangzhan.com

    工作时间:周一至周五,9:00-17:30,节假日休息

    关注微信
    微信扫一扫关注我们

    微信扫一扫关注我们

    关注微博
    返回顶部