readAsText
Summary
Returns partial Blob data representing the number of bytes currently loaded (as a fraction of the total), decoded into memory according to the encoding determination.
Method of apis/file/FileReaderapis/file/FileReader
Syntax
var = FileReader.readAsText(blob, encoding);
Parameters
blob
- Data-type
- Blob
encoding
- Data-type
- any
(Optional)
Defaults to UTF-8.
Return Value
Returns an object of type DOM NodeDOM Node
Type: HRESULT
This method can return one of these values.
S_OK
Examples
var reader = new FileReader();
reader.onload = function(e) {
var text = reader.result;
}
reader.readAsText(file);
Notes
This method asynchronously starts reading the contents of the specified File. When the read operation is complete, readyState
will become DONE
and the onloadend
event handler (that is, callback), if present, will be invoked. At that time, the result
property contains the contents of the file as a text string.
Related specifications
- W3C File API Specification
- W3C Working Draft
Attributions
Microsoft Developer Network: Windows Internet Explorer API reference Article