-1

I need to upload files whatever i browse from one html input file element. If i select a file first time using that file element and again changing that selection by picking some other file, finally i need to submit form by having that both file selection.

<html>

 <script>
     function loadFiles(){
        var form = document.getElementById("imageUploadForm");
        var file = document.getElementById("fileSelector");
        var mi = document.createElement("input");
        mi.setAttribute('type', 'file');
        mi.setAttribute('value', file.value);
        document.getElementById("imageUploadForm").innerHTML = form.innerHTML + mi;
        file.value = "";
     }
 </script>
 <form>
    <div id="imageUploadForm">
    <input type="file" onchange="loadFiles()" id="fileSelector"/>
    <input type="submit" value="Upload">
    </div>
 </form>
</html>

Thanks in advance.

Surendheran
  • 187
  • 1
  • 18

1 Answers1

0

You can easily select multiple files with one input:

<input type="file" name="img" multiple>
apohl
  • 1,913
  • 27
  • 30
  • not sure if this is the answer on the question but if you select in multiple and realize you need to add more files like when selecting in different file location? – jned29 May 26 '20 at 21:29