I am trying to read the contents of a file (any format but testing with a hello.txt with contents= 'hello') and output the binary string to the console in Meteor, I'm new to the framework. Whenever I check the console there is a new entry of 'undefined'. What am I missing here?
HTML
<div>
Select a file:
<input type="file" id="fileInput">
</div>
JS:
if (Meteor.isClient) {
window.onload = function() {
var fileInput = document.getElementById('fileInput');
fileInput.addEventListener('change', function(e) {
// Put the rest of the demo code here.
var file = fileInput.files[0];
var reader = new FileReader();
reader.onload = function(e) {
var rawData = reader.result;
}
var output = reader.readAsBinaryString(file);
console.log(output);
});
}
}
Aucun commentaire:
Enregistrer un commentaire