JSFiddle - React, Tailwind, and code Playground

HTML

<button>Select files</button>
<button>Submit</button>

JavaScript

var files = [];

$("button:first").on("click", function(e) {
    $("<input>").prop({
        "type": "file",
        "multiple": true
    }).on("change", function(e) {
        files.push(this.files);
    }).trigger("click");
});

$("button:last").on("click", function(e) {
    var xhr = new XMLHttpRequest();
    xhr.open("POST", "/echo/html/", true);
    var data = new FormData();
    $.each(files, function() {
        $.each(this, function() {
            console.log("appending %s", this.name);
            data.append("files", this);
        });
    });
    xhr.onreadystatechange = function(e) {
        if(xhr.readyState === 4) {
            console.log("done");
        }
    };
    xhr.send(data);
});