Skip to content Skip to sidebar Skip to footer

Why Is No File Type Returned When Adding An MKV File To A File Input?

I am attempting to grab the file/mime type of a file when it is being added to a basic HTML file input. My basic HTML:
<

Solution 1:

"The official mimetype of an MKV file is video/x-matroska"

This is unfortunately not true. IANA still hasn't endorsed it in its list of official MIME types.

Now, it is possible that in some browsers + OS configuration you would actually have it, because the type checking is made quite leniently by browsers, generally checking against only the extension and a map of known extensions to MIME. Some browsers don't have such list themselves, and thus will use the OS one, which your user may control.

But in my case (macOs) no browser seems to show anything else than the empty string...

Firefox actually has an open issue about it.

However, you can workaround that issue by setting explicitly the extension in your accept attribute:

<input type="file" accept="video/*,.mkv">

Solution 2:


Post a Comment for "Why Is No File Type Returned When Adding An MKV File To A File Input?"