输入banner图图片脚本导航/分类

readfile输出文件到浏览器页面,想要改变这个页面的title

$pdf_name=basename($_SERVER['REQUEST_URI']);
$pdf_dir=registry("DOC_ROOT")."test/". $csrUid. "/" . $pdf_name;
if (!file_exists($pdf_dir)) {
    die ("文件不存在!") ;
}
//$pdf_dir = http://xxxx.com/test/test-2015/download.pdf
header("Content-type: application/pdf");
readfile($pdf_dir);   //  1
exit;

像上面所述,// 1 处输出在页面输出了pdf内容,但是页面的title没有变,我现在想把这个输出pdf的页面title改为$pdf_name的值,用了ob_start()/ob_end_flush()/echo "$pdf_name"; ,还是失败了,不能改变这个title。
求解该怎么书写呢?

回复内容:

$pdf_name=basename($_SERVER['REQUEST_URI']);
$pdf_dir=registry("DOC_ROOT")."test/". $csrUid. "/" . $pdf_name;
if (!file_exists($pdf_dir)) {
    die ("文件不存在!") ;
}
//$pdf_dir = http://xxxx.com/test/test-2015/download.pdf
header("Content-type: application/pdf");
readfile($pdf_dir);   //  1
exit;

像上面所述,// 1 处输出在页面输出了pdf内容,但是页面的title没有变,我现在想把这个输出pdf的页面title改为$pdf_name的值,用了ob_start()/ob_end_flush()/echo "$pdf_name"; ,还是失败了,不能改变这个title。
求解该怎么书写呢?

你输出的内容是 application/pdf 类型的, 所以浏览器拿什么内容做标题, 你是没办法通过输出 </code>来控制的.</p> <p>目前实验的结果是:<br> chrome 在显示 pdf文件时, 标题是显示的URL地址.<br> IE 是直接显示下载的(如果安装的有PDF阅读的插件不排除是直接显示,而非下载的情况).<br> Firefox 在加载中的时候,显示的是PDF的文件名, 加载完成之后,显示的是PDF中的标题.<br> 以这个URL为例: http://www.st.com/web/en/resource/technical/document/datasheet/CD00001...<br> Chrome:<br><img data-src="http://img.gxlcms.com//img/bVlTDu"></p> <p>IE:<br><img data-src="http://img.gxlcms.com//img/bVlTDv"><br> Firefox:<br><img data-src="http://img.gxlcms.com//img/bVlTDy"></p> </body></html> </div> </div> <script type="text/javascript" src="/layui/layui.js"></script> <script> layui.use('code', function(){ layui.code({ elem: 'pre', //默认值为.layui-code about:false, title:'readfile输出文件到浏览器页面,想要改变这个页面的title代码块', encode: true //是否转义html标签。默认不开启 }); }); </script> <footer class="comm-footer"> <ul class="channels"> <li> <a target="_top" href="/system/">操作系统</a> </li><li> <a target="_top" href="/down/">程序下载</a> </li><li> <a target="_top" href="/jquery/">jquery插件库</a> </li><li> <a target="_top" href="/jiaoben/">编程</a> </li><li> <a target="_top" href="/db/">数据库</a> </li><li> <a target="_top" href="/tools/">在线工具</a> </li><li> <a target="_top" href="/framebook/">框架书籍</a> </li><li> <a target="_top" href="/xitongjiaocheng/">系统教程</a> </li><li> <a target="_top" href="/ruanjianxiazai/">软件下载</a> </li> </ul> <ul class="versions"> <li> <a href="https://m.gxlcms.com" class="active">触屏版</a> </li> <li> <a href="https://www.gxlcms.com" target="_top">电脑版</a> </li> </ul> <p><a href="https://beian.miit.gov.cn/" target="_blank" style="color:#ffffff"></a><script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?6c9b8cea1903c9f813f150c04aeebc3c"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script></p> </footer> </body> </html>