<tfoot id='A9qEh'></tfoot>

<small id='A9qEh'></small><noframes id='A9qEh'>

  • <i id='A9qEh'><tr id='A9qEh'><dt id='A9qEh'><q id='A9qEh'><span id='A9qEh'><b id='A9qEh'><form id='A9qEh'><ins id='A9qEh'></ins><ul id='A9qEh'></ul><sub id='A9qEh'></sub></form><legend id='A9qEh'></legend><bdo id='A9qEh'><pre id='A9qEh'><center id='A9qEh'></center></pre></bdo></b><th id='A9qEh'></th></span></q></dt></tr></i><div id='A9qEh'><tfoot id='A9qEh'></tfoot><dl id='A9qEh'><fieldset id='A9qEh'></fieldset></dl></div>

      <legend id='A9qEh'><style id='A9qEh'><dir id='A9qEh'><q id='A9qEh'></q></dir></style></legend>
      • <bdo id='A9qEh'></bdo><ul id='A9qEh'></ul>

        使用 header() 为动态 pdf 重写 URL 中的文件名

        using header() to rewrite filename in URL for dynamic pdf(使用 header() 为动态 pdf 重写 URL 中的文件名)
      1. <small id='lbjfx'></small><noframes id='lbjfx'>

        <legend id='lbjfx'><style id='lbjfx'><dir id='lbjfx'><q id='lbjfx'></q></dir></style></legend>
          <bdo id='lbjfx'></bdo><ul id='lbjfx'></ul>
            • <i id='lbjfx'><tr id='lbjfx'><dt id='lbjfx'><q id='lbjfx'><span id='lbjfx'><b id='lbjfx'><form id='lbjfx'><ins id='lbjfx'></ins><ul id='lbjfx'></ul><sub id='lbjfx'></sub></form><legend id='lbjfx'></legend><bdo id='lbjfx'><pre id='lbjfx'><center id='lbjfx'></center></pre></bdo></b><th id='lbjfx'></th></span></q></dt></tr></i><div id='lbjfx'><tfoot id='lbjfx'></tfoot><dl id='lbjfx'><fieldset id='lbjfx'></fieldset></dl></div>
                  <tbody id='lbjfx'></tbody>
                <tfoot id='lbjfx'></tfoot>

                  本文介绍了使用 header() 为动态 pdf 重写 URL 中的文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个生成 pdf 报告的 php 脚本.当我们去保存 pdf 文档时,Acrobat 建议的文件名是 report_pdf,因为 php 脚本名为 report_pdf.php.我想动态命名 pdf 文件,因此我不必在每次保存时都为报告键入适当的名称.

                  I have a php script that generates a pdf report. When we go to save the pdf document, the filename that Acrobat suggests is report_pdf, since the php script is named report_pdf.php. I would like to dynamically name the pdf file, so I don't have to type the appropriate name for the report each time that I save it.

                  在新闻组中询问,有人建议这样做,其中 filename="July Report.pdf" 是报告的预期名称

                  Asking on a news group, someone suggested this, where filename="July Report.pdf" is the intended name of the report

                  <?
                  header('Content-Type: application/pdf');
                  header('Content-disposition: filename="July Report.pdf"');
                  

                  但它不起作用.我做错了吗,或者这会起作用吗?这是 mod_rewrite 的工作吗?

                  But it doesn't work. Am I doing it wrong, or will this work at all? Is this a job for mod_rewrite?

                  <人力资源>所以我都试过了


                  So I've tried both

                  header('Content-disposition: inline; filename="July Report.pdf"');
                  

                  header('Content-disposition: attachment; filename="July Report.pdf"');
                  

                  (不是同时),也不适合我.这是我的虚拟主机的问题吗?对于这个 url,这是我的代码:

                  ( not at the same time ) and neither work for me. Is this a problem with my web host? For this url, here's my code:

                  <?
                  header('Content-disposition: inline; filename="July Report.pdf"');
                  
                  // requires the R&OS pdf class
                  require_once('class.ezpdf.php');
                  require_once('class.pdf.php');
                  
                  // make a new pdf object
                  $pdf = new Cpdf();
                  // select the font
                  $pdf->selectFont('./fonts/Helvetica');
                  $pdf->addText(30,400,30,'Hello World');
                  $pdf->stream();
                  
                  ?>
                  

                  推荐答案

                  试试:

                  header('Content-Disposition: attachment; filename="July Report.pdf"');
                  

                  header('Content-Disposition: inline; filename="July Report.pdf"');
                  

                  另一种选择是使用 $_SERVER['PATH_INFO'] 传递您的July Report.pdf" - 示例链接可能是:

                  Another option would be to use the $_SERVER['PATH_INFO'] to pass your "July Report.pdf" - an example link might be:

                  <a href="report_pdf.php/July%20Report.pdf?month=07">
                  

                  该文件应默认保存为July Report.pdf" - 其行为应与旧 php 脚本完全相同,只需更改生成 pdf 链接的代码即可.

                  That file should default to saving as "July Report.pdf" - and should behave exactly like your old php script did, just change the code that produces the link to the pdf.

                  这篇关于使用 header() 为动态 pdf 重写 URL 中的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                  1. <legend id='7y26v'><style id='7y26v'><dir id='7y26v'><q id='7y26v'></q></dir></style></legend>

                      <tfoot id='7y26v'></tfoot>
                        • <i id='7y26v'><tr id='7y26v'><dt id='7y26v'><q id='7y26v'><span id='7y26v'><b id='7y26v'><form id='7y26v'><ins id='7y26v'></ins><ul id='7y26v'></ul><sub id='7y26v'></sub></form><legend id='7y26v'></legend><bdo id='7y26v'><pre id='7y26v'><center id='7y26v'></center></pre></bdo></b><th id='7y26v'></th></span></q></dt></tr></i><div id='7y26v'><tfoot id='7y26v'></tfoot><dl id='7y26v'><fieldset id='7y26v'></fieldset></dl></div>
                            <tbody id='7y26v'></tbody>

                          <small id='7y26v'></small><noframes id='7y26v'>

                          • <bdo id='7y26v'></bdo><ul id='7y26v'></ul>