webkitdirectory属性与文件夹选择演示页面
展示
代码
-
HTML:
<input type="file" id="filepicker" name="fileList" webkitdirectory multiple /> <ul id="listing"></ul>
-
JS:
filepicker.addEventListener('change', (event) => { for (const file of event.target.files) { const item = document.createElement('li'); item.textContent = file.webkitRelativePath; listing.appendChild(item); } }, false);