JSFiddle - React, Tailwind, and code Playground

by crysfel

HTML

<input type="file" id="filesToUpload" multiple="" />
<ul id="fileList"><li>No Files Selected</li></ul>

JavaScript

window.addEventListener('load', function() {    
    
    document.getElementById('filesToUpload').addEventListener('change',function(){
        var input = document.getElementById('filesToUpload');
        var ul = document.getElementById('fileList');


        while (ul.hasChildNodes()) {
            ul.removeChild(ul.firstChild);
        }


        for (var x = 0; x < input.files.length; x++) {
            var li = document.createElement('li');
            li.innerHTML = 'File ' + (x + 1) + ':  ' + input.files[x].name;
            ul.appendChild(li);
        }
    
    });
    
});