<div>
<h1>Upload directories</h1>
<input type="file" id="file-uploader" webkitdirectory />
<ul id="pathList">
</ul>
</div>
html {
height: 100%;
}
body {
background: #000000;
color: #FFFFFF;
}
div {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
font-family: 'Roboto Mono', monospace;
}
const fileUploader = document.getElementById('file-uploader');
const pathList = document.getElementById('pathList');
function removeAllChildNodes(parent) {
while (parent.firstChild) {
parent.removeChild(parent.firstChild);
}
}
fileUploader.addEventListener('change', (event) => {
const files = event.target.files;
console.log('files', files);
removeAllChildNodes(pathList);
[...files].forEach((file, index) => {
let path = document.createElement('li');
path.innerHTML = file.webkitRelativePath;
pathList.appendChild(path);
});
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.