2014-05-16 158 views
1

我有一个文件要上传到我的网页。输入标签与接受

<input type="file" id='fFile' name="template"/> 

但我希望它只显示rptdesign文件。任何人都可以请帮忙?

而且我已经加入

<input type="file" id='fXls' name="template" 
accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"/> 

为XLSX,但是当出现对话框,在下拉列表中选择,但所有的所有文件的所有文件和XLSX。可以选择Xlsx吗?

回答

1

查找到MIME_Types:

<input accept="audio/*|video/*|image/*|MIME_type"> 

不同的媒体MIME类型here!

注列表:在接受输入标签的属性不会在Internet Explorer 9和早期版本的支持。

编辑

在你的Tomcat的配置文件,去到你的web.xml。

如果向下滚动,您会发现MIME类型映射。在这里你可以指定服务器的扩展名!

例(web.xml中):

<mime-mapping> 
     <extension>asx</extension> 
     <mime-type>video/x-ms-asf</mime-type> 
</mime-mapping> 

希望帮助!

+0

我没有找到rptdesign文件的任何MIME类型。 – Biswas

+0

你是否在使用tomcat? :) @Biswas –

+0

遐,我使用的是tomcat服务器:) – Biswas