There is an XML file in the files folder.
By clicking on the button, it is "going" and should be downloaded.
How can this be done with a header (or some other way) so that when saving the page does not appear?
if you know the header function, this is good. but do not be lazy to read the documentation for it:
If you need to warn the user about the need to save sent data, such as a generated PDF file, you can use the
Content-Dispositionheader, which substitutes the recommended file name and causes the browser to show the download dialog.
Example # 1 Download Dialog
// Будем передавать PDF header('Content-Type: application/pdf'); // Он будет называться downloaded.pdf header('Content-Disposition: attachment; filename="downloaded.pdf"'); // Исходный PDF-файл original.pdf readfile('original.pdf'); in your case, the mime-type should specify text/xml or application/xml , well, and if the file is going to dynamically, then output it via echo/print :
$xml = new SimpleXMLElement("<root></root>"); // формируем xml // .... // сохраняем в файл $xml->asXML("/path/to/your/file.xml"); // отправляем заголовки для скачивания header('Content-Type: application/xml'); header('Content-Disposition: attachment; filename="myfile.xml"'); // скидываем сам файл print $xml->asXML(); <a href="/files/my/file.xml" target="_blank">скачать</a> - teranreadfile('path/to/my/file.xml') - teranSource: https://ru.stackoverflow.com/questions/816329/
All Articles