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
Post a Comment