html - Sync a FileReader in a for loop: Javascript -


i trying implement javascript program read bunch of csv files particular directory containing sub-directories. so, thinking of using javascript read multiple files using webkitdirectory , reading files , using java push them.

html form

<input id="csv" type="file" multiple webkitdirectory directory> <input type="button" onclick="readcsv()" value="submit"> 

javascript read files

function readcsv(){     var fileinput = document.getelementbyid("csv");     var filecount = fileinput.files.length;     if( filecount != 0) {         alert(filecount);         var reader;         (var = 0; < filecount; i++) {             reader = new filereader();             reader.onload = function ()  {                 document.getelementbyid('out').innerhtml = reader.result;                // once file read, send javaservlet save on server.             };             reader.readasbinarystring(fileinput.files[i]);         }     } else {         alert("select file");     } } 

the problem facing here code runs when 1 file selected breaks when multiple files selected. think problem in sync read. couldn't find way either sync read or pause loop while reader object reads file.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -