I\'ve got a problem with a javascript Filereader which returns the error Uncaught TypeError: Failed to execute \'readAsDataURL\' on \'FileReader\': parameter 1 is not of type \'
i was getting a similar error when i would click the input but then instead of choosing an attachment, clicking cancel. so if I just wrapped the readAsDataURL call with an if statement checking if the file existed, it fixed it. see below.
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]);
}
}