The readAsText method is used to read the contents of the specified Blob or File. When the read operation is complete, the readyState is changed to DONE, the loadend event is triggered, and the result attribute contains the contents of the file as a text string.
Syntax
instanceOfFileReader.readAsText(blob[, encoding]);
Parameters
blob- The
BloborFilefrom which to read. - encoding Optional
- A string specifying the encoding to use for the returned data. By default, UTF-8 is assumed if this parameter is not specified.
Specifications
| Specification | Status | Comment |
|---|---|---|
| File API The definition of 'FileReader' in that specification. |
Working Draft | Initial definition |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
| Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|---|
| Basic support | 7 | Yes | 3.6 | 10 | 11 | 6 |
| Feature | Android webview | Chrome for Android | Edge mobile | Firefox for Android | Opera Android | iOS Safari | Samsung Internet |
|---|---|---|---|---|---|---|---|
| Basic support | ? | Yes | Yes | 32 | 11 | 6.1 | ? |
See also
Document Tags and Contributors
Tags:
Contributors to this page:
fscholz,
sideshowbarker,
erikadoyle,
ziyunfei,
NumerHero,
Sebastianz,
teoli,
hanna,
dhritzkiv,
Jeremie,
dabus
Last updated by:
fscholz,