Я использую Chrome 12 на Mac OS X и включил в документ jQuery 1.6.1.
Я пытаюсь прочитать файл со следующим кодом, при чтении файла возникает ошибка, так что вызывается this.error.onerror (), но FileReader-Object this.reader больше не существует, и я не могу получить ошибку.Я также не уверен, почему возникает ошибка, это обычный текстовый документ, который я хочу прочитать.
function FileHandler(files, action) {
console.log('FileHandler called.');
this.files = files;
this.reader = new FileReader();
this.action = action;
this.handle = function() {
console.log('FileHandler.handle called.');
for (var i = 0; i < this.files.length; i++) {
this.reader.readAsDataURL(files[i]);
}
}
this.upload = function() {
console.log('FileHandler.upload called.');
console.log(this.reader);
data = {
content: this.reader.result
}
console.log(data);
}
this.error = function() {
console.log('An error occurred while reading a file.');
console.log(this.reader.error);
}
this.reader.onload = this.upload;
this.reader.onerror = this.error;
}
Этот код создает следующий вывод консоли: http://cl.ly/0j1m3j0o3s071Y1K3A25