如何让浏览器下载exe而不是在浏览器窗口中打开它? [英] How can I get browsers to download an exe instead of opening it in the browser window?

查看:236
本文介绍了如何让浏览器下载exe而不是在浏览器窗口中打开它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站,我想让浏览器用户下载一个exe。



我用一个非常简单的HTML文件来测试它,我加载到网页浏览器与文件>打开。 身体看起来像这样:

 < body> 
< a href =http://www.example.com/myprogram.exetarget =_ self>点击下载exe< / a>
< a href =http://www.example.com/myprogram.ziptarget =_ self>点击下载zip< / a>
< / body>

问题是这样的:当我点击第一个链接(myprogram.exe),浏览器IE8以及FireFox)将myprogram.exe直接流入浏览器窗口:我看到很多二进制文件。



当我点击第二个链接(myprogram。 zip),浏览器询问我是否要打开文件或将其保存到磁盘,这是我预期的.exe文件。



这是唯一的.exe下载导致这个奇怪的行为。我经常下载了.exes,浏览器总是问我是打开文件还是保存到磁盘。



有没有什么需要在网站本身设置,或主机或...?

解决方案

您需要更正网络服务器发送的内容类型。听起来像是声称数据是 text / plain 。我的mime.types文件建议exe文件应该是 application / x-msdos-program



如果你使用Apache ,请参阅 http://httpd.apache.org/docs/1.3/ mod / mod_mime.html#addtype (或您正在使用的版本的手册中的类似页面)。


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". The "body" looks something like this:

<body>
<a href="http://www.example.com/myprogram.exe" target="_self">click to download exe</a>
<a href="http://www.example.com/myprogram.zip" target="_self">click to download zip</a>
</body>

The issue is this: when I click on the first link (myprogram.exe), the browser (IE8 as well as FireFox) streams the myprogram.exe directly into the browser window: I see a whole lot of binary.

When I click on the second link (myprogram.zip), the browser asks me if I would like to open the file or save it to disk, which is what I expected to happen with the .exe.

This is the ONLY .exe download that causes this strange behaviour. I have downloaded .exes often and the browsers always ask me whether to open the file or save to disk.

Is there something that needs to be set on the web site itself, or the host or ... ?

解决方案

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).

这篇关于如何让浏览器下载exe而不是在浏览器窗口中打开它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆