FileReader: FileReader() constructor
The FileReader()
constructor creates a new FileReader.
For details about how to use FileReader
, see Using files from web applications.
Syntax
new FileReader()
Parameters
None.
Examples
The following code snippet shows creation of a FileReader
object using the FileReader()
constructor and subsequent usage of the object:
function printFile(file) {
const reader = new FileReader();
reader.onload = (evt) => {
console.log(evt.target.result);
};
reader.readAsText(file);
}
Specifications
Specification |
---|
File API # filereaderConstrctr |
Browser compatibility
BCD tables only load in the browser