谁能解释下这个下载

pow6965921pow 2014-10-19 09:40:21
if(is_file($file)) {
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=".basename($file));
readfile($file);
exit;
}else{
echo "文件不存在!";
exit;
}


application/force-download是什么
Content-Disposition: attachment是什么 filename是什么 readfile是什么
...全文
65 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuzuning 2014-10-19
  • 打赏
  • 举报
回复
application/force-download 是一种 mime 类型,用于告知接收方:这是一个文件下载 Content-disposition 是 mime 协议的扩展 Content-Disposition: attachment 告知接收方:后面的 filename 属性是参考文件名 通常浏览器会弹出一个下载对话框,并显示文件名 readfile 是 php 函数 从函数名上就可看出他的功能 读(read)文件(file)

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧