html input=“file“ 只显示指定文件类型 xls、xlsx、csv

<!-- 只显示csv文件 -->
<input id="fileSelect" type="file" accept=".csv" />  

<!-- 只显示xlsx文件 -->
<input id="fileSelect" type="file" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" />  

<!-- 只显示xls文件 -->
<input id="fileSelect" type="file" accept="application/vnd.ms-excel" />  

<!-- 只显示csv、xls、xlsx文件 -->
<input id="fileSelect" type="file" accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" />  

可能会发生的情况:

由于我自己是Mac系统,所以我的xls无法实现效果,但是在Windows和Linux是没有问题的。

可接受的类型:

  CSV 文件(.csv),请使用:

<input type="file" accept=".csv" />

  或者 

<input type="file" accept="text/csv" />

  Excel Files 2003-2007  (.xls),请使用:

<input type="file" accept="application/vnd.ms-excel" />

  Excel Files 2010  (.xlsx),请使用: 

<input type="file" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" />

  文本文件 (.txt),请使用: 

<input type="file" accept="text/plain" />

  图像文件 (.png / .jpg / etc),请使用: 

<input type="file" accept="image/*" />

  HTML文件 (.htm,.html),请使用:

<input type="file" accept="text/html" />

  视频文件 (.avi,.mpg,.mpeg,.mp4),请使用:

<input type="file" accept="video/*" />

  音频文件 (.mp3,.wav等),请使用:

<input type="file" accept="audio/*" />

  对于 PDF文件,请使用:

<input type="file" accept=".pdf" /> 

 

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值