The file input accept
attribute works pretty well. However, there are some browser incompatibilities especially when you only want to select certain file types, ie, mimetypes .
For example, if you want to only accept markdown and pdf files (see code below), webkit browsers allow one to select pdfs but ignore any markdown mimetype I can find . Whereas Firefox ignores both mimetypes and allows you to select any file type.
Does anyone know how to get webkit browsers to accept markdown files?
<label for='file'>upload</label>
<input id='file' accept='application/pdf, text/x-markdown' multiple='multiple' type='file'>
Now you can simply use .md to filter the markdown file
<label for='file'>upload</label> <input id='file' accept='.md' multiple='multiple' type='file'>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.