A constructor function producing an object that provides methods to asynchronously read a File or a Blob, and an event model to obtain the results of these reads.
Syntax
var reader = new FileReader();
DOM Information
Inheritance Hierarchy
The FileReader does not inherit from any class or interface.Members
The FileReader object has these types of members:
Events
The FileReader object has these events.
| Event | Description |
|---|---|
| onabort |
Fires when a read or creation operation is aborted by calling the abort method. |
| onerror |
Fires when an error occurs when using the msStreamReader or FileReader object. |
| onload |
Fires when the creation of, or read by, an msStreamReader or FileReader object successfully completes. |
| onloadend |
Fires when the request to create or read an msStreamReader or FileReader object completes, even if the request fails. |
| onloadstart |
Fires at the start of the creation of, or read by, an msStreamReader or FileReader object. |
| onprogress |
Contains a function pointer to the |
Methods
The FileReader object has these methods.
| Method | Description |
|---|---|
| abort |
Aborts a read operation by an MSStreamReader or FileReader object. |
| readAsArrayBuffer | |
| readAsDataURL | |
| readAsText |
Properties
The FileReader object has these properties.
| Property | Description |
|---|---|
|
The error that occurred while reading the file. | |
|
Contains a constant indicating the current state of the FileReader/msStreamReader object. | |
|
The result of the read operation. |
Remarks
When the FileReader constructor is invoked, a new FileReader object is returned.
This FileReader object enables asynchronous reads on individual File or Blob objects by firing progress events as the read occurs to event handler methods attached to the FileReader object.
Examples
var reader = new FileReader(); // Setup callback functions: reader.onprogress = updateProgress; reader.onload = loaded; reader.onerror = errorHandler; // Read file into memory as UTF-8: reader.readAsText(readFile, "UTF-8");
Build date: 11/28/2012