转载自:https://blog.youkuaiyun.com/dosming/article/details/77891560
<p>显示 .xls, .xlsx, .csv 文件...</p>
<input type="file" accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" ID="fileSelect" runat="server" />
<p>只显示 Excel (.xlsx) 文件...</p>
<input type="file" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ID="fileSelect" runat="server" />
<p>只显示 Excel (.xls) 文件...</p>
<input type="file" accept="application/vnd.ms-excel" ID="fileSelect" runat="server" />
<p>只显示图片.</p>
<input type="file" accept="image/*" ID="fileSelect" runat="server" />
<p>只显示文本文件...</p>
<input type="file" accept="text/plain" ID="fileSelect" runat="server" />
<p>只显示html文件.</p>
<input type="file" accept="text/html" ID="fileSelect" runat="server" />
<p>只显示 video 文件..</p>
<input type="file" accept="video/*" ID="fileSelect" runat="server" />
<p>只显示 audio 文件...</p>
<input type="file" accept="audio/*" ID="fileSelect" runat="server" />
<p>只显示 .WAV 文件...</p>
<input type="file" accept=".wav" ID="fileSelect" runat="server" />
<p>只显示 .PDF 文件...</p>
<input type="file" accept=".pdf" ID="fileSelect" runat="server" />
---------------------
作者:DosMing
来源:优快云
原文:https://blog.youkuaiyun.com/dosming/article/details/77891560
版权声明:本文为博主原创文章,转载请附上博文链接!
本文介绍了如何通过HTML的<input>标签中的accept属性来限制文件上传的类型,包括各种文档、图片、音频和视频等格式,并提供了具体的代码示例。
1万+

被折叠的 条评论
为什么被折叠?



