JSFiddle - React, Tailwind, and code Playground
HTML
<form id="test" method="post" action="/echo/html/" enctype="multipart/form-data">
<input type="hidden" value='{"success":true}' name="html" />
<input name="file" id="file" type="file" multiple="multiple"/>
</form>
JavaScript
var form = document.querySelector('#test');
form.addEventListener('change', change);
function change(event){
var iframe = document.createElement('iframe');
iframe.name = 'iframex';
form.target = iframe.name;
iframe.style.width = 0;
iframe.style.height = 0;
document.body.appendChild(iframe);
iframe.addEventListener('load', load);
form.submit();
}
function load(event){
alert(this.contentWindow.document.body.textContent);
}