XML download by browser, without opening the file [duplicate]

0

I need the system to download an XML file, release the file itself without opening it in the browser, how?

    
asked by anonymous 03.08.2016 / 13:39

1 answer

1

Yes, it does. Do so

<?php 
header('Content-disposition: attachment; filename="file.xml"');
header('Content-type: "text/xml"; charset="utf8"');
readfile('file.xml');
?>

or

<?php 
header('Content-disposition: attachment; filename="file.xml"');
header('Content-type: "text/xml"; charset="utf8"');
echo "<?xml version="1.0" encoding="UTF-8"?>
<root>
<tag>Oi</tag>
</root>
";
?>
    
03.08.2016 / 15:16