Skip to content Skip to sidebar Skip to footer

How Can I Get Browsers To Download An Exe Instead Of Opening It In The Browser Window?

I have a website from which I want to enable browser users to download an exe. I am testing it with a very simple HTML file which I load into the web browser with 'File>Open'. T

Solution 1:

You need to correct the content-type your webserver is sending. It sounds like it is claiming that the data is text/plain. My mime.types file suggests exe files should be application/x-msdos-program

If you are using Apache, see http://httpd.apache.org/docs/1.3/mod/mod_mime.html#addtype (or the similar page in the manual for the version you are using).

Solution 2:

You need to set the Content-Disposition HTTP header.

UPDATE: The HTTP headers are typically controlled in the web server, e.g., Apache.

As another poster mentions, most browsers should download .exe files as an attachment automatically if the server is sending the correct Content-Type header. How to do this varies from server to server. Here's an article on setting MIME types (another name for content-type) in IIS. In Apache, it is typically done by editing the file your TypesConfig directive points to.

Solution 3:

See this

How To Raise a "File Download" Dialog Box for a Known MIME Type

When you serve a document from a Web server, you might want to immediately prompt the user to save the file directly to the user's disk, without opening it in the browser. However, for known MIME (Multipurpose Internet Mail Extensions) types such as Microsoft Word ("application/ms-word"), the default behavior is to open the document in Internet Explorer.

You can use the content-disposition header to override this default behavior. Its format is:

Content-disposition: attachment; filename=fname.ext

Solution 4:

In the end it required AddType application/x-octet-stream exe being applied.

Thanks to all the answerers who pointed me that way.

Post a Comment for "How Can I Get Browsers To Download An Exe Instead Of Opening It In The Browser Window?"