0

I use the following code to download an xml file

<?php
header('Content-type: text/xml');
header('Content-Disposition: attachment; filename="download.xml"');
echo simplexml_load_file('temp.xml');
unlink('temp.xml');
?>

I would like to redirect to index.php after this. How do I do this?

header('location...) and meta refresh do not work

AgeDeO
  • 3,137
  • 2
  • 25
  • 57

2 Answers2

2

Well because you send the header and content this can't be done.

You have to redirect first and then let the file download on the target site.

Maarkoize
  • 2,601
  • 2
  • 16
  • 34
-1

Make your website change the url two times with javascript:

<script>
  location.href="your_php_file_that_downloads_xml.php";
  location.href="/other/site";
</script>
L3viathan
  • 26,748
  • 2
  • 58
  • 81