1 2 3 4 5 6 7 8 9 10 11
window.onload = function() { const fileInput = document.querySelector("#file-js input[type=file]"); if (fileInput !== null) { fileInput.onchange = () => { if (fileInput.files.length > 0) { const fileName = document.querySelector("#file-js .file-name"); fileName.textContent = fileInput.files[0].name; } } }; }