Is it recommended to set the length to be inherited from Angular right? If so, why am I getting this error: "MyPostsComponent.html: 7 ERROR TypeError: Cannot read the 'length' of undefined property" when fileList.length is greater than 0?
onFileSelection(event){
const fileList: FileList = event.target.filse;
if (fileList.length > 0){
const file: File = fileList[0];
this.myFire.uploadFile(file).then(data => {
//TO DO
this.notifier.display('success','Picture Uploaded!');
console.log(data['fileUrl']);
})
.catch(err => {
this.notifier.display('error', err.message);
});
}
}
In my HTML code:
<input type="file" (change)="onFileSelection($event)" placeholder="Upload a file" accept=".png, .jpeg, .jpg">