class js.html.FileReader extends EventTarget

Available on js

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. File objects may be obtained in one of two ways: from a FileList object returned as a result of a user selecting files using the <input> element, or from a drag and drop operation's DataTransfer object.

To create a FileReader, simply do the following:

var reader = new FileReader();

See Using files from web applications for details and examples.



Documentation for this class was provided by MDN.

Class Fields

static var DONE:Int

The entire read request has been completed.

static var EMPTY:Int

No data has been loaded yet.

static var LOADING:Int

Data is currently being loaded.

Instance Fields

var error:FileError

The error that occurred while reading the file. Read only.

var onabort:EventListener

Called when the read operation is aborted.

var onerror:EventListener

Called when an error occurs.

var onload:EventListener

Called when the read operation is successfully completed.

var onloadend:EventListener

Called when the read is completed, whether successful or not. This is called after either onload or onerror.

var onloadstart:EventListener

Called when reading the data is about to begin.

var onprogress:EventListener

Called periodically while the data is being read.

var readyState:Int

Indicates the state of the FileReader. This will be one of the State constants. Read only.

var result: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. Read only.

function new():Void

function abort():Void

function readAsArrayBuffer(blob:Blob):Void

function readAsDataURL(blob:Blob):Void

function readAsText(blob:Blob, ?encoding:String):Void