Safari <input type="file" accept="video/*"> ignores mp4 files

VideoFile IoSafariAttributesMp4

Video Problem Overview


I am using an HTML file input like this:

<input type="file" accept="video/*"> 

to allow my users to upload videos to my site. This works as expected in all modern browsers (only permitting the user to select video files) except Safari.

From what I can tell Safari seems to interpret the accept="video/*" attribute as accept="*.mov" ignoring most, if not all, other video formats / extensions (webm, m4v, etc).

Any suggestions on how to get the select dialog to allow only common video filetypes (not just .mov's) in Safari?

Video Solutions


Solution 1 - Video

I found that the following accept string will add mp4 and m4v to the list of file types that safari will accept:

accept="video/mp4,video/x-m4v,video/*"

I'm not sure what the mime type is for webm videos but if you can look that up you should be able to tack it on to the accept string. The trick is to specify the mime type, just using a file extension won't work.

Solution 2 - Video

You can take a look at webkit source code ~/Source/WebCore/platform/MIMETypeRegistry.cpp.

These types are customized by Apple for Safari, and may not be working on other browsers.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestioncdanzigView Question on Stackoverflow
Solution 1 - VideosbennettView Answer on Stackoverflow
Solution 2 - VideoAlan DongView Answer on Stackoverflow