I have prepared an XML string in PHP and I would like to let the user download the string in an XML file.
Is it possible to offer the user the download (e.g. text.xml) without physically saving the xml file to the server?
Simply click the File button (the 3 lines), and click Save Page As. For example, I went to xml-sitemaps.com/sitemap.xml and clicked Save Page As. It saved as XML to my local machine and loaded as such. Without any HTML.
If you're trying to download a file from the GitHub Web App, just right-click on the Raw button and select “Save Link As”. That should download the file as an XML to your machine.
<?php
header('Content-type: text/xml');
header('Content-Disposition: attachment; filename="text.xml"');
echo $xml_contents;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With