加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > PHP > 正文

PHP 强制性文件下载功能的函数代码(任意文件格式)

发布时间:2020-05-24 21:39:44 所属栏目:PHP 来源:互联网
导读:PHP强制性文件下载函数代码,使用此函数为用户提供强制性的文件下载功能。

<div class="codetitle"><a style="CURSOR: pointer" data="23875" class="copybut" id="copybut23875" onclick="doCopy('code23875')"> 代码如下:<div class="codebody" id="code23875">
/****
@file - path to file
/
function force_download($file)
{
if ((isset($file))&&(file_exists($file))) {
header("Content-length: ".filesize($file));
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $file . '"');
readfile("$file");
} else {
echo "No file selected";
}
}

这里是摘自脚本之家之前发布的文章。更多的技巧可以参考。
收集的二十一个实用便利的PHP函数代码

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读