1

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

Manuel
  • 41
  • 1
  • 7

1 Answers1

1

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:

Evil_skunk
  • 3,040
  • 4
  • 30
  • 42