问题描述
使用上传文件,我目前使用的一些硬支持它们,这取决于用户代理字符串浏览器的codeD检查:
Using the HTML5 File API to upload files, I am currently using some hardcoded checking of the browsers that support them, depending on the user agent string:
internal bool IsHtml5FileUploadCapable
{
get
{
var browser = Request.Browser;
var n = browser.Browser.ToLowerInvariant();
var major = browser.MajorVersion;
var minor = browser.MinorVersion;
return
n.Contains(@"chrome") && major >= 6 ||
n.Contains(@"ie") && major >= 10 ||
n.Contains(@"firefox") && (major >= 3 && minor > 6 || major >= 4) ||
n.Contains(@"opera") && (major >= 11 && minor >= 5 || major >= 12) ||
n.Contains(@"safari") && major >= 4;
}
}
我爱用的是内置的App_Browsers文件的功能与 的HttpBrowserCapabilities
类。
我的问题:
是否可以推断出一个浏览器来直接从浏览器功能,支持HTML5文件API的能力?
Is it possible to deduce the ability of a browser to support the HTML5 File API directly from the browser capabilities?
推荐答案
这可能不是你问什么事情,但其对JavaScript库一看,被称为Modernizr的(的),可能是你的用例是有用的。它的,当然,客户端检查和不服务器端之一。
It may not be exactly what you are asking about, but having a look on the javascript library, called Modernizr ( http://www.modernizr.com/docs/ ), might be useful for your usecase. It's, of course, client-side check and not server-side one.
这是能够检测相当多的HTML5特性。
It is capable of detecting quite a lot of HTML5 features.
这篇关于有没有办法使用App_Browsers文件来检测支持HTML5文件API的机会吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!