简体   繁体   中英

php - generate and download multiple file

i'm using php and the need is to generate a pdf (i'm using fpdf) and an xml file with the same content. The pdf / xml is called by an html form with post parameter. Unfortunately gets downloaded only one page (pdf or xml). How can i solve the problem?

form page

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

page1

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

page2

<?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");
        ...
    ?>

i'd like on the form submission that both pdf and xml gets download

Thanks

Unfortunately that's not directly possible in one call. Each HTTP response can return for example one response, one file or a redirect.

Possible solutions:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM