Проблема решена, прочтите комментарий
Третья проблема с файлом HTML5 API: Я все еще использую Chrome 12 в Mac OS X Snow Leopard, и я все еще пытаюсь читать файлы с помощью HTML5 File API, но вызывается FileHandler.error () из-за ошибки SECURITY_ERR. Файл, который я пытаюсь прочитать, представляет собой обычный файл .txt с моего рабочего стола, но он не работает с другими файлами, хотя я могу открывать их с помощью обычных приложений.
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 the file.');
console.log(this.reader.error);
}
this.reader.onload = this.upload.bind(this);
this.reader.onerror = this.error.bind(this);
}
Код генерирует следующий вывод консоли: http://cl.ly/1x1o2F0l2m3L1T2c0H0i