1

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

1 Answer 1

1

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;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.