栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

HTML Input =“ file”接受属性文件类型(CSV)

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

HTML Input =“ file”接受属性文件类型(CSV)

好吧,这很尴尬。。。我找到了我想要的解决方案,而且再简单不过了。我使用以下代码来获得所需的结果。希望这对以后的人有所帮助。感谢大家的帮助。

<input id="fileSelect" type="file" accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" />

有效接受类型:

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

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

对于 Excel文件97-2003 (.xls),请使用:

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

对于 Excel Files 2007+ (.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" />

注意:

如果您试图显示Excel CSV文件(

.csv
),请 不要 使用:

  • text/csv
  • application/csv
  • text/comma-separated-values
    仅适用于Opera )。

如果您尝试显示 特定的文件类型 (例如a

WAV
PDF
),那么这几乎总是可行的…

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


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/465000.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号