如何解决我的JSP页面上需要浏览按钮来选择文件夹不是文件
这是我在JSP页面上想要的示例,
我可以浏览文件,但要求是浏览文件夹。
有人可以帮忙吗?
解决方法
有一个HTMLInputElement.webkitdirectory
属性,您可以将其添加到input
元素中。这是非标准实现;使用时提供后备。
这是一个片段:
function onFolderChange({ target }) {
const files = target.files;
// file is a FileList,array methods are not supported.
[...files].forEach(console.log); // Needs a recursive function since `file` could be another FileList (a folder)
}
const folderInput = document.getElementById("folderInput");
folderInput.addEventListener('change',onFolderChange);
<label>
Select a folder
<input id="folderInput" type="file" webkitdirectory directory multiple>
</label>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。