最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to select only multiple .csv files in html5 input tag? - Stack Overflow

programmeradmin3浏览0评论

I am using the html5 input tag to multiselect only .csv files. I have so far

<input type="file" id="files" name="files[]" accept=".csv" multiple />

but when I click browse, it shows all file types. How can I get this to work?

Thanks.

I am using the html5 input tag to multiselect only .csv files. I have so far

<input type="file" id="files" name="files[]" accept=".csv" multiple />

but when I click browse, it shows all file types. How can I get this to work?

Thanks.

Share asked Mar 16, 2014 at 5:22 omegaomega 44k90 gold badges286 silver badges523 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

Try:

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

Or take a look at this solution.

As per the docs, accept is used to specify mime types, not file extensions. Try accept="text/csv" instead.

发布评论

评论列表(0)

  1. 暂无评论