The FileReader object lets web applications asynchronously read the contents of files (or raw data buffers) stored on the user's computer, using File or Blob objects to specify the file or data to read.

Documentation FileReader by Mozilla Contributors, licensed under CC-BY-SA 2.5.

See also:

Static variables

@:value(2)staticinlineread onlyDONE:Int = 2

@:value(0)staticinlineread onlyEMPTY:Int = 0

@:value(1)staticinlineread onlyLOADING:Int = 1

Constructor

new()

Throws:

null

DOMError

Variables

read onlyerror:DOMException

A DOMException representing the error that occurred while reading the file.

onabort:Function

A handler for the abort event. This event is triggered each time the reading operation is aborted.

onerror:Function

A handler for the error event. This event is triggered each time the reading operation encounter an error.

onload:Function

A handler for the load event. This event is triggered each time the reading operation is successfully completed.

onloadend:Function

A handler for the loadend event. This event is triggered each time the reading operation is completed (either in success or failure).

onloadstart:Function

A handler for the loadstart event. This event is triggered each time the reading is starting.

onprogress:Function

A handler for the progress event. This event is triggered while reading a Blob content.

read onlyreadyState:Int

A number indicating the state of the FileReader. This is one of the following:

EMPTY 0 No data has been loaded yet.
LOADING 1 Data is currently being loaded.
DONE 2 The entire read request has been completed.

read onlyresult:Dynamic

The file's contents. This property is only valid after the read operation is complete, and the format of the data depends on which of the methods was used to initiate the read operation.

Methods

abort():Void

Aborts the read operation. Upon return, the readyState will be DONE.

readAsArrayBuffer(blob:Blob):Void

Starts reading the contents of the specified Blob, once finished, the result attribute contains an ArrayBuffer representing the file's data.

Throws:

null

DOMError

readAsBinaryString(filedata:Blob):Void

Starts reading the contents of the specified Blob, once finished, the result attribute contains the raw binary data from the file as a string.

Throws:

null

DOMError

readAsDataURL(blob:Blob):Void

Starts reading the contents of the specified Blob, once finished, the result attribute contains a data: URL representing the file's data.

Throws:

null

DOMError

readAsText(blob:Blob, ?label:String):Void

Starts reading the contents of the specified Blob, once finished, the result attribute contains the contents of the file as a text string.

Throws:

null

DOMError

Inherited Variables

Inherited Methods

Defined by EventTarget

addEventListener(type:String, listener:Function, ?options:EitherType<AddEventListenerOptions, Bool>, ?wantsUntrusted:Bool):Void

addEventListener(type:String, listener:EventListener, ?options:EitherType<AddEventListenerOptions, Bool>, ?wantsUntrusted:Bool):Void

Register an event handler of a specific event type on the EventTarget.

Throws:

null

DOMError

dispatchEvent(event:Event):Bool

Dispatch an event to this EventTarget.

Throws:

null

DOMError

removeEventListener(type:String, listener:Function, ?options:EitherType<EventListenerOptions, Bool>):Void

removeEventListener(type:String, listener:EventListener, ?options:EitherType<EventListenerOptions, Bool>):Void

Removes an event listener from the EventTarget.

Throws:

null

DOMError