FileReader: error event

The error event is fired when the read failed due to an error (for example, because the file was not found or not readable).

Bubbles No
Cancelable No
Interface ProgressEvent
Event handler property FileReader.onerror


const fileInput = document.querySelector('input[type="file"]');
const reader = new FileReader();

function handleSelected(e) {
    const selectedFile = fileInput.files[0];
    if (selectedFile) {

        reader.addEventListener('error', () => {
            console.error(`Error occurred reading file: ${}`);

        reader.addEventListener('load', () => {
            console.error(`File: ${} read successfully`);


fileInput.addEventListener('change', handleSelected);


Specification Status
File API Working Draft

Browser compatibility

Update compatibility data on GitHub
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
error eventChrome Full support YesEdge Full support 12Firefox Full support YesIE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes


Full support  
Full support

See also