我正在运行一个经典的ASP网站,我的在线用户可以在内部消息系统中附加文件。但是每当他们上传一个文件扩展名超过3个字符时,服务器就会给我返回404。
像 mypicture.jpg
这样的文件可以正常工作,但像 mydocument.docx
这样的文件不起作用?
有什么建议吗?
我正在运行一个经典的ASP网站,我的在线用户可以在内部消息系统中附加文件。但是每当他们上传一个文件扩展名超过3个字符时,服务器就会给我返回404。
像 mypicture.jpg
这样的文件可以正常工作,但像 mydocument.docx
这样的文件不起作用?
有什么建议吗?
在mime map属性中,IIS6只会服务于已将文件扩展名映射到mime类型的文档,无论是对于服务器还是站点。为了服务于更近期的Office 2007文档类型,您需要添加额外的映射。
有许多地方可以找到这些新mime类型的列表。
以下是一个简单的方法; 来自IIS的Office 2007 mime类型:
.docm,application/vnd.ms-word.document.macroEnabled.12 .docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document .dotm,application/vnd.ms-word.template.macroEnabled.12 .dotx,application/vnd.openxmlformats-officedocument.wordprocessingml.template .potm,application/vnd.ms-powerpoint.template.macroEnabled.12 .potx,application/vnd.openxmlformats-officedocument.presentationml.template .ppam,application/vnd.ms-powerpoint.addin.macroEnabled.12 .ppsm,application/vnd.ms-powerpoint.slideshow.macroEnabled.12 .ppsx,application/vnd.openxmlformats-officedocument.presentationml.slideshow .pptm,application/vnd.ms-powerpoint.presentation.macroEnabled.12 .pptx,application/vnd.openxmlformats-officedocument.presentationml.presentation .xlam,application/vnd.ms-excel.addin.macroEnabled.12 .xlsb,application/vnd.ms-excel.sheet.binary.macroEnabled.12 .xlsm,application/vnd.ms-excel.sheet.macroEnabled.12 .xlsx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet .xltm,application/vnd.ms-excel.template.macroEnabled.12 .xltx,application/vnd.openxmlformats-officedocument.spreadsheetml.template
Adding all mime-types to IIS in one step is very simple:
The easiest way to do this is stopping IIS and editing the metabase XML file (
C:\WINDOWS\system32\inetsrv\MetaBase.xml
) using a text editor. Search for the<IIsMimeMap Location="/LM/MimeMap" />
element and append the lines above to the MimeMap attribute
服务器可能没有为docx和其他文件扩展名定义mime类型。