2012-01-18 152 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.