The FileReader onerror handler receives an Event object, not an Error object, as a parameter, but an error can be accessed from the FileReader object, as instanceOfFileReader.error

// Callback from a <input type="file" onchange="onChange(event)">
function onChange(event) {
  var file =[0];
  var reader = new FileReader();
  reader.onerror = function(event) {
    alert("Failed to read file!\n\n" + reader.error);


Browser compatibility

BCD tables only load in the browser