Проблема решена, прочитайте комментарий
Третья проблема, с которой я столкнулся с API-интерфейсом для файлов HTML5:
Я все еще использую 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