javascript - Get file contents from Ractive on-change event -


i'm trying headers of csv file i've attached file input. fire function on change of file input , check if there files in event , start filereader onload can contents onload function doesn't fired. there i'm missing?

ractive.on('getheaders', function(target) {   // check file file   if(target.node.files !== undefined) {     var reader = new filereader();     var headers = [];      reader.onload = function(e) {       console.log(e);     };   } }); 

you need pass files reader, this:

ractive.on('getheaders', function(target) {   // check file file   if(target.node.files !== undefined) {      var headers = [];     target.node.files.foreach(function(file){      var reader = new filereader();      reader.onload = function(e) {       console.log(e);       console.log(reader.result);     };     reader.readasdataurl(file);     });         } }); 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -