jquery.support to detect JavaScript's File API?

时光怂恿深爱的人放手 提交于 2019-12-03 05:55:14

It does not seem to be implementd in jQuery, but you could check yourself: http://jsfiddle.net/pimvdb/RCz3s/.

The files property of an <input type='file'> returns an empty FileList if it's implemented, and otherwise it is not defined (i.e. it is undefined).

var support = (function(undefined) {
    return $("<input type='file'>")    // create test element
                 .get(0)               // get native element
                 .files !== undefined; // check whether files property is not undefined
})();

Another way to check is just by checking the presence of the File API types:

var FileApiSupported = !!('File' in window &&
                          'FileReader' in window &&
                          'FileList' in window &&
                          'Blob' in window);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!