132
rated 0 times
[
134]
[
2]
/ answers: 1 / hits: 38557
/ 14 Years ago, thu, november 4, 2010, 12:00:00
Can someone give me an example of using the FileReader API go get contents of a file in chrome?
It seems to be returning undefined
for me.
<!doctype html>
<html>
<script>
function handle_files(files) {
console.log(files)
reader = new FileReader()
ret = []
for (i = 0; i < files.length; i++) {
file = files[i]
console.log(file)
text = reader.readAsText(file) //readAsdataURL
console.log(text) //undefined
ret.push(text)
}
console.log(ret) // [undefined]
}
</script>
<body>
FileReader Test
<input type=file onchange=handle_files(this.files)>
</body>
</html>
More From » html