如何检测浏览器中的目录选择功能? [英] How to detect directory select capability in browsers?
本文介绍了如何检测浏览器中的目录选择功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
显然,在< input type =文件/>
具有 webkitdirectory
属性。但是,我怎样才能测试,如果浏览器实际上是能够选择文件夹和遍历文件?
解决方案
也许这是一个解决方案问题:
$ b
函数isInputDirSupported(){
var tmpInput = document.createElement('input');
if(''webkitdirectory'in tmpInput
||'mozdirectory'in tmpInput
||'odirectory'in tmpInput
||'msdirectory'in tmpInput
|| 'tmpInput'中的'directory')返回true;
返回false;
}
I am trying to find out if browser has ability to select folders, not just multiple files. Current Chrome supports this (example: http://html5-demos.appspot.com/static/html5storage/demos/upload_directory/index.html).
Apparently, it works in Chrome when <input type="file" />
has webkitdirectory
attribute. But how can I test if browser is actually capable of selecting folders and iterating through files?
解决方案
Maybe this is a solution for your problem:
function isInputDirSupported() {
var tmpInput = document.createElement('input');
if ('webkitdirectory' in tmpInput
|| 'mozdirectory' in tmpInput
|| 'odirectory' in tmpInput
|| 'msdirectory' in tmpInput
|| 'directory' in tmpInput) return true;
return false;
}
这篇关于如何检测浏览器中的目录选择功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文