问题描述
我正在使用以下代码将 pdf 流式传输到浏览器:
I am using the following code to stream a pdf to the browser:
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: public");
header("Content-type:application/pdf");
header("Content-Disposition:attachment;filename=file.pdf");
echo $pdf;
工作正常,除了(无论如何在 Chrome 中)它只是保存文件file.pdf" - 它不会提示另存为对话框,因此我可以重命名文件,如果我选择的话.
Works fine, except (in Chrome anyhow) it just saves the file "file.pdf" - it does not prompt a Save As dialog so I can rename the file, if I choose.
我怀疑这可能是那些依赖于浏览器的事情之一,但是在流式传输 pdf 以供下载时,是否可以强制使用 php 标头的另存为对话框?
I suspect this may be one of those browser-dependent things, but is it possible to force a Save As dialog with the php headers when streaming a pdf for download?
感谢(提前)您的帮助
推荐答案
他们很可能 在下载之前询问每个文件的保存位置未选中(高级设置).如果是这种情况,您无能为力,因为这是他们的偏好.
They most likely have Ask where to save each file before downloading unchecked (Advanced Settings). If this is the case, there's nothing you can do as this is their preference.
这篇关于流式传输 PDF 附件时如何强制使用另存为对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)