【发布时间】:2016-12-05 07:41:26
【问题描述】:
Image here shows how one can manipulate the browser to choose a different file我已经就类似问题经历了大量的问题和答案,但到目前为止没有找到任何帮助。目前的方法有很多,其中比较突出的是:
<input type="file" id="fileSelect"
accept=".csv,
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,
application/vnd.ms-excel">
但是,这并不能解决我的问题。用户仍然可以在浏览器中将文件类型更改为 All Files 并选择不同的文件。我想知道是否有任何方法可以限制用户只选择 excel 文件。
【问题讨论】:
-
您可以在 javascript 中验证扩展。
-
@p4sh4 - 不是重复的。我以前经历过,但它并没有解决我的问题。
-
Dom 的回答无助于实现我想要实现的目标。
标签: javascript html excel file input