php如何强制下载文件,php 强制下载文件实现代码
发布日期:2021-06-24 14:52:27 浏览次数:2 分类:技术文章

本文共 631 字,大约阅读时间需要 2 分钟。

复制代码 代码如下:

$file = 'monkey.gif';

if (file_exists($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, post-check=0, pre-check=0');

header('Pragma: public');

header('Content-Length: ' . filesize($file));

ob_clean();

flush();

readfile($file);

exit;

}

?>

?

header("Content-Type: application/force-download");

header("Content-Disposition: attachment; filename=ins.jpg");

readfile("imgs/test_Zoom.jpg");

?>

转载地址:https://blog.csdn.net/weixin_33458486/article/details/115951179 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:php继承exten,stylus中文文档 » 继承(@extend) » 张鑫旭-鑫空间-鑫生活
下一篇:matlab与情人节,情人节MATLAB画爱心的小礼物

发表评论

最新留言

路过按个爪印,很不错,赞一个!
[***.219.124.196]2024年04月26日 14时00分58秒