The FileReader()
constructor creates a new FileReader.
For details about how to use FileReader
, see Using files from web applications.
Syntax
var reader = new FileReader();
Parameters
None.
Example
The following code snippet shows creation of a FileReader
object using the FileReader()
constructor and subsequent usage of the object:
function printFile(file) {
var reader = new FileReader();
reader.onload = function(evt) {
console.log(evt.target.result);
};
reader.readAsText(file);
}
Specifications
Specification | Status | Comment |
---|---|---|
File API | Working Draft | Initial definition |
See also
FileReader() by Mozilla Contributors is licensed under CC-BY-SA 2.5.