Safari <输入类型=“文件"接受=“视频/*"&gt;忽略 mp4 文件 [英] Safari &lt;input type=&quot;file&quot; accept=&quot;video/*&quot;&gt; ignores mp4 files

查看:37
本文介绍了Safari <输入类型=“文件"接受=“视频/*"&gt;忽略 mp4 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用这样的 HTML 文件输入:

I am using an HTML file input like this:

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

允许我的用户将视频上传到我的网站.这在除 Safari 之外的所有现代浏览器(仅允许用户选择视频文件)中都能正常工作.

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.

据我所知,Safari 似乎将 accept="video/*" 属性解释为 accept="*.mov" 忽略了大多数(如果不是全部),其他视频格式/扩展(webm、m4v 等).

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).

关于如何让选择对话框在 Safari 中只允许常见的视频文件类型(不仅仅是 .mov)有什么建议吗?

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

推荐答案

我发现下面的accept字符串会将mp4和m4v添加到safari将接受的文件类型列表中:

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/*"

我不确定 webm 视频的 mime 类型是什么,但如果你能查到,你应该能够将它附加到接受字符串上.诀窍是指定 mime 类型,仅使用文件扩展名是行不通的.

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.

这篇关于Safari <输入类型=“文件"接受=“视频/*"&gt;忽略 mp4 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆