Answers for "Failed to execute 'readAsDataURL' on 'FileReader': parameter 1 is not of type 'Blob'."

1

core.js:4352 ERROR TypeError: Failed to execute 'readAsArrayBuffer' on 'FileReader': parameter 1 is not of type 'Blob'.

onSelectFile(event) {
    let reader = new FileReader();
    reader.onload = function(){
      let output: any = document.getElementById('blah');
      output.src = reader.result;
    }
    if(event.target.files[0]){
      reader.readAsDataURL(event.target.files[0]);
    }
}
Posted by: Guest on October-27-2020
0

Failed to execute 'readAsDataURL' on 'FileReader': parameter 1 is not of type 'Blob'.

//This this happen  when you pass the array to  readAsDataURL function
// like this 

let file  = e.target.files;  //incorrect
let file  = e.target.files[0]; //correct 
getBase64(file);


function getBase64(file) {
  return new Promise((resolve, reject) => {
    const reader = new FileReader();
    reader.readAsDataURL(file);
    reader.onload = () => resolve(reader.result);
    reader.onerror = error => reject(error);
  });
}

//readAsDataURL  read only single object on the whole array
Posted by: Guest on October-01-2021

Code answers related to "Failed to execute 'readAsDataURL' on 'FileReader': parameter 1 is not of type 'Blob'."

Code answers related to "Javascript"

Browse Popular Code Answers by Language