views:

39

answers:

4

I am writing a web based files administrator. How can I have an html file be downloaded when its link is clicked instead of displayed.

+6  A: 

On server side, when serving file, add this header:

Content-Disposition: attachment; filename="document.html"

For examle in PHP you'd do:

header('Content-Disposition: attachment; filename="document.html"');
Pēteris Caune
A: 

Set the Content-Type header on your HTTP response to 'application/octet-stream'.

In ASP.net/C#

Response.ContentType = "application/octet-stream";
Ryan Michela
A: 

The server would need to return a different MIME Type when that file is requested such as application/octet-stream.

Oliver Weichhold
A: 

In the response headers, set Content-Disposition to "attachment; filename=something.html"

hrnt