Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
63
rated 0 times [  67] [ 4]  / answers: 1 / hits: 17515  / 13 Years ago, mon, june 20, 2011, 12:00:00

I use Chrome 12 on Mac OS X and I've included jQuery 1.6.1 within the document.



I try to read the contents of a file as text and save it in a data-object with the following function:



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 seams to be a valid file-object and this.reader is a fresh instance of type FileReader. This code creates the following console output:



http://cl.ly/1Y2b383G2F272x1m1P0N



enter


More From » html

 Answers
13

That's not the way it works according to the docs. You should call the readAsText() function, and when it's completed the result is stored in .result.


[#91612] Saturday, June 18, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cruzs

Total Points: 710
Total Questions: 113
Total Answers: 100

Location: Nepal
Member since Sat, Jul 18, 2020
4 Years ago
;