views:

50

answers:

2

Hello. I have this .xml file http://www.anitard.org/layouts/blogger_layouts/spicenwolf/spice_and_wolf_www.anitard.org.xml

When i make a link to this in my website you will try to view that document, but that is not possible. How do i make it downloadable? So when i click on my link the .xml document will request to download it.

+1  A: 

It says it is data of mime type application/xml, but it's not well formed XML. Change the content-type header to something else more appropriate or make the document well formed XML.

Brabster
A: 

When you connect to it with a plain link, you don't have any way of telling the browser that it should download it. It would then depend on how the browser is configured to handle documents with the appropriate MIME type. For XML, I suspect it is universally displayed. Of course, the user could simply save the page. If you want to force it to download rather than display, I suggest a handler that takes the document title as a parameter and returns a response with "content-disposition: attachment; filename=...". Then link to the handler instead of the document. Note that your documents, then, do not need to be in the readable portion of your web site. Moving them would prevent someone from accidentally including a direct link to the document.

<a href='/example.com/downloader.ashx?doc=mydoc.xml'>mydoc.xml</a>
tvanfosson