<input id="fileItem" type="file" />FileList / notebook
FileList
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const file = document.getElementById("fileItem").files[0];<input id="myfiles" multiple type="file" />
<pre class="output">Selected files:</pre>.output {
overflow: scroll;
margin: 1rem 0;
height: 200px;
}const output = document.querySelector(".output");
const fileInput = document.querySelector("#myfiles");
fileInput.addEventListener("change", () => {
for (const file of fileInput.files) {
output.innerText += `\n${file.name}`;
}
});