2012-01-18 109 views
0

I have a folder named Test. I have some .xls files and .txt , .doc files in it.为什么我的<a href="test.xls"> is working and .txt is not?

In the html I have

<p> <a href="../../Test/Stats.xls">Download excel file </a> </p> 
- when I click on this link it is opening a download window (Working fine) 

<p> <a href="../../Test/Stats.txt">Download Text file </a> </p> 

<p> <a href="../../Test/Stats.doc">Download excel file </a> </p> 

But these 2 are not working. Instead of opening a download window they are going to that .doc file link and saying that the page cannot be found.

why the download window is coming for .xls and not for .do or .doc? How can I fix this??

+0

找不到页面?文件夹中的文件名Stats.doc和Stats.txt真的存在吗? – 2012-01-18 16:12:59

+0

您可能需要调整您的服务器的MIME类型。 – 2012-01-18 16:14:26

+1

浏览器对于文本文件(.txt)的默认行为是打开页面,就像它是一个网页并且不提示下载。这并不能解释为什么会出现404错误。如果您使用的是IIS 7,则可能没有.DOC/.DOCX和.TXT的MIME类型作为允许的扩展名。可能存在阻止IIS_USER帐户访问权限的问题。您是否使用过像Fiddler这样的工具来观看对IIS的请求并查看HTTP状态码?你有没有检查你的IIS日志? – 2012-01-18 16:15:50

回答

1

You need to configure your server's MIME types, otherwise either the file will not be served up (and you'll get a 404) or the browser will not know how to handle the type of file.

See this article获取更多信息。

+0

的警告我为.doc添加了MIME类型,但仍然不能正常工作:( – SmilingLily 2012-01-18 16:32:41

+0

您确定您指向的路径存在且位于网站的虚拟目录中?查看事件ID 1309的详细信息......我敢打赌,您会看到类似“系统找不到指定路径”的内容。 – RoccoC5 2012-01-18 20:10:59

1

Sounds silly, but I'm guessing that you need to check the file names and references to them and make sure they are exactly the same. Unless you are on a Windows box, case sensitivity is something to take into account too.

相关问题