Need to use FlatFile file instead of mdb

85 views Asked by At

I have used mdb DB with the below Architecture

HTML <-> JavaScript <-> DB (mdb file)

Now I want to relpace DB with FlatFile (instead of mdb file)

HTML <--> JavaScript <--???--> DB (FlatFile)

So please guide me how to replace this

Please share sample logic to access Flatfile(DB) data using JavaScript

1

There are 1 answers

1
Joakim M On BEST ANSWER

Try This

JSFIDDLE

HTML

<input type="file" id="fileid" name="yourfile" >

Javascript

document.getElementById('fileid').onchange = function(){

  var yourfile = this.files[0];

  var filereader = new FileReader();
  filereader.onload = function(progressEvent){
    // Entire file
    console.log(this.result);

    // By lines
    var lines = this.result.split('\n');
    for(var line = 0; line < lines.length; line++){
      console.log(lines[line]);
    }
  };
  filereader.readAsText(yourfile);
};