JavaScripture
Contribute via GitHub Feedback

FileReader : EventTarget

FileReader is used to read the contents of a Blob or File.

Constructors

new FileReader() : FileReader

Constructs a new FileReader.

Example:

Run

Results:

 

Instance Properties

error : Error  

The error encountered during load.

Example:

Run

Results:

 

readyState : Number  

The current state of the reader. Will be one of EMPTY, LOADING, or DONE.

Example:

Run

Results:

 

result : Object  

The result from the previous read. The result will be either a String or an ArrayBuffer. The result is only available after the load event fires.

Example:

Run

Results:

 

Instance Methods

abort() : undefined

Stops the current read operation.

readAsArrayBuffer(blob : Blob) : undefined

Begins reading from blob as an ArrayBuffer. The result will be stored on this.result after the 'load' event fires. See also Blob.arrayBuffer().

Example:

Run

Results:

 

readAsDataURL(blob : Blob) : undefined

Begins reading from blob as a 'data:' url string. The result will be stored on this.result after the 'load' event fires.

Example:

Run

Results:

 

readAsText(blob : Blob, [encoding : String]) : undefined

Begins reading from blob as a string. The result will be stored on this.result after the 'load' event fires. For the valid values of encoding, see character sets. See also Blob.text().

Example:

Run

Results:

 

Instance Events

onabort / 'abort'  
listener(event : ProgressEvent) : undefined

Called when the read is aborted with abort().

Example:

Run

Results:

 

onerror / 'error'  
listener(event : ProgressEvent) : undefined

Called when there is an error during the load.

Example:

Run

Results:

 

onload / 'load'  
listener(event : ProgressEvent) : undefined

Called when a read operation successfully completes.

Example:

Run

Results:

 

onloadend / 'loadend'  
listener(event : ProgressEvent) : undefined

Called after a read completes (either successfully or unsuccessfully).

Example:

Run

Results:

 

onloadstart / 'loadstart'  
listener(event : ProgressEvent) : undefined

Called after starting a read operation.

Example:

Run

Results:

 

onprogress / 'progress'  
listener(event : ProgressEvent) : undefined

Called during a read operation to report the current progress.

Example:

Run

Results:

 

FileReader Properties

DONE : Number    

The value returned by readyState after the load event has fired.

EMPTY : Number    

The value returned by readyState before the one of the read methods has been called.

LOADING : Number    

The value returned by readyState after one of the read methods has been called but before the load event has fired.