我正在使用谷歌浏览器的文件夹上传功能,可以在这里找到更多信息: 如何在我的代码中使用谷歌浏览器11的上传文件夹功能?
我有一个按钮,当点击它时会触发一个输入框。 我的问题是如何检查浏览器是否支持webkitdirectory? 这样我就可以隐藏我的按钮或提示用户使用chrome来使用这项服务。
<button>Upload Folder</button>
<input type="file" name="file[]" multiple webkitdirectory>
<script>
$("button").click(function(e) {
/* TODO: Detect webkitdirectory support */
if(webkitdirectory)
$('input').trigger('click');
else
alert('Use Chrome!');
});
</script>