The FileReader()
constructor creates a new FileReader.
For details about how to use FileReader
, see Using files from web applications.
The FileReader()
constructor creates a new FileReader.
For details about how to use FileReader
, see Using files from web applications.
js
new FileReader()
None.
The following code snippet shows creation of a FileReader
object using the FileReader()
constructor and subsequent usage of the object:
js
function printFile(file) {
const reader = new FileReader();
reader.onload = (evt) => {
console.log(evt.target.result);
};
reader.readAsText(file);
}
Specification |
---|
File API # filereaderConstrctr |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
FileReader |
6 | 12 | 3.6 | 10 | ≤12.1 | 6 | 3 | 18 | 32 | ≤12.1 | 6 | 1.0 |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/FileReader/FileReader