我在Mac OS X上使用Chrome 12,文档中包含了jQuery 1.6.1。
我尝试使用以下函数将文件内容作为文本读取并保存到一个数据对象中:
this.upload = function(file) {
console.log('FileHandler.upload called with ' + file.name + '.');
console.log(file);
console.log(this.reader);
data = {
content: this.reader.readAsText(file)
}
console.log('Content: ' + data.content);
}
"file" 看起来是一个有效的文件对象,而 "this.reader" 是 FileReader 类型的一个新实例。此代码创建以下控制台输出:
http://cl.ly/1Y2b383G2F272x1m1P0N