开发者社区> 问答> 正文

请教thinkphp如何实现弹窗下载?

header("Pragma: public");
header("Cache-control: max-age=".$expire);

//header('Cache-Control: no-store, no-cache, must-revalidate');
header("Expires: " . gmdate("D, d M Y H:i:s",time()+$expire) . "GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s",time()) . "GMT");
header("Content-Disposition: attachment; filename=".$showname);
header("Content-Length: ".$length);
header("Content-type: ".$type);
header('Content-Encoding: none');
header("Content-Transfer-Encoding: binary" );
if($content == '' ) {
readfile($filename);
}else {
echo($content);
}
exit();

这是http里面的一段代码,可是我用它只能读出到浏览器中。请问有什么方法点击链接如“下载”便出现一个弹框然后自己输入保存名字存起来呢?

展开
收起
落地花开啦 2016-06-12 10:12:44 2170 0
1 条回答
写回答
取消 提交回答
  • 喜欢技术,喜欢努力的人

    header("Content-type: application/octet-stream;");
    或者修改 httpd 的 mime.types 里面对应的文件类型为 application/octet-stream

    2019-07-17 19:33:17
    赞同 展开评论 打赏
问答分类:
PHP
问答地址:
问答排行榜
最热
最新

相关电子书

更多
QQ移送页面框架优化实践 立即下载
QQ移动页面框架优化实践 立即下载
函数计算最佳实践:快速开发一个分布式 Puppeteer 网页截图服务 立即下载