W3cubDocs

/Web APIs

FileReader: FileReader() constructor

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨July 2015⁩.

Note: This feature is available in Web Workers.

The FileReader() constructor creates a new FileReader.

For details about how to use FileReader, see Using files from web applications.

Syntax

new FileReader()

Parameters

None.

Examples

The following code snippet shows creation of a FileReader object using the FileReader() constructor and subsequent usage of the object:

function printFile(file) {
  const reader = new FileReader();
  reader.onload = (evt) => {
    console.log(evt.target.result);
  };
  reader.readAsText(file);
}

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet WebView Android WebView on iOS
FileReader 6 12 3.6 ≤12.1 6 18 32 ≤12.1 6 1.0 3 6

See also

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/FileReader/FileReader