Lets say that i have a valid xml string. Is there any way to put in an iframe and generate som kind of save button? Either a link to the file, which you can right click on and use "save target as". Or maybe the javascript function document.execCommand('SaveAs', true); (since it will only need to work in IE). Thanks
Add a comment
|
1 Answer
You can make a server-side page that will output the data you want to save as the response body and by adding the header:
content-disposition: attachment; filename=FILE_NAME.xml
this will make the browser open the save dialog for that file (you can name the file as you want by changing FILE_NAME
for example, with php you would do:
$data = file_get_contents("1.xml"); //set the data you want to output to this variable
header("content-disposition: attachment; filename=my_xml.xml");
header("content-length: ".filesize("1.xml"));
echo $data;