【问题标题】:php - generate and download multiple filephp - 生成和下载多个文件
【发布时间】:2018-11-10 10:13:37
【问题描述】:

我使用的是php,需要生成一个pdf(我使用的是fpdf)和一个内容相同的xml文件。 pdf / xml 由带有 post 参数的 html 表单调用。 不幸的是,只下载了一页(pdf 或 xml)。我该如何解决这个问题?

表单页面

<form name="aaa" id="aaa" action="page1.php" method="POST" target="_blank">
        ....
        <div><input type="submit" value="Insert"></div>
</form>

第1页

<?php
    //do stuff and generate pdf
    header("Location: page2.php");
?>

第2页

<?php
        //do same stuff above and generate xml
        header("Cache-Control: public");
        header("Content-Description: File Transfer");
        header("Content-Disposition: attachment; filename=test.xml");
        header("Content-Type: text/xml");
        header("Content-Transfer-Encoding: binary");
        ...
    ?>

我想要同时下载 pdf 和 xml 的表单提交

谢谢

【问题讨论】:

    标签: php header fpdf


    【解决方案1】:

    不幸的是,这在一次通话中无法直接实现。 例如,每个 HTTP 响应都可以返回一个响应、一个文件或一个重定向。

    可能的解决方案:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-17
      • 2015-10-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多