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是什么
application/force-download 是一种 mime 类型,用于告知接收方:这是一个文件下载
Content-disposition 是 mime 协议的扩展
Content-Disposition: attachment 告知接收方:后面的 filename 属性是参考文件名
通常浏览器会弹出一个下载对话框,并显示文件名
readfile 是 php 函数
从函数名上就可看出他的功能 读(read)文件(file)
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号