This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

readAsDataURL

Summary

Returns the complete data of blob as a Data URL, essentially a Base64-encoded string of the file data.

Method of apis/file/FileReaderapis/file/FileReader

Syntax

var  = FileReader.readAsDataURL(blob);

Parameters

blob

Data-type
Blob

Represents a chunk of immutable raw data.

Return Value

Returns an object of type DOM NodeDOM Node

Type: HRESULT

This method can return one of these values.

S_OK

Examples

var reader = new FileReader();

reader.onload = function(e) {
  var dataURL = reader.result;
}

reader.readAsDataURL(file);

Notes

This method asynchronously starts reading the contents of the specified File or Blob. When the read operation is complete, readyState will become DONE and the onloadend event handler (that is, callback), if present, will be invoked. At that time, the result property contains a data URL string that encodes the file’s data.

Related specifications

W3C File API Specification
W3C Working Draft

Attributions