1

The file input accept attribute works pretty well. However, there are some browser incompatibilities especially when you only want to select certain file types, i.e., 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?

http://jsfiddle.net/JZ5jz/

<label for='file'>upload</label>

<input id='file' accept='application/pdf, text/x-markdown' multiple='multiple' type='file'>
2
  • Did you try changing the order? Is webkit simply taking only the first accept value? Commented Apr 30, 2014 at 10:07
  • just tried changing the order, that doesn't matter, it will take a comma delineated list for most mimetypes, e.g., application/pdf, application/msword Commented Apr 30, 2014 at 16:57

1 Answer 1

2

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'>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.