0
我正在尝试读取文件的内容(任何格式,但用内容为'hello'的hello.txt进行测试)并将二进制字符串输出到Meteor中的控制台,我是新来的框架。每当我检查控制台时,都会有一个'undefined'的新条目。我在这里错过了什么?Meteor中的filereader API如何读取二进制字符串
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);
});
}
}