I need do upload file which accepts XLS files only file size limit 5mb Angular 13?
HTML
<input name="file" type="file" (change)="onSelectFile($event)" required/> <button type ="file"> </button>
Ts file
onSelectFile(event:any){
const allowed_type = ['application/xslx']
if (this.file.size >5000 * 1024 && this.files.type !== allowed_type) {
this.warning = true;
} else {
this.warning = false;
}
}
here I can only get warning msg on size limit not file type
I need both the validations happen.
also tried in this way:
if (this.file.size >5000 * 1024) {
this.warning = true;
} else if (this.files.type !== allowed_type){
this.warning = true;
}else{
this.warning = false;
}
Here I should not allow more 5mb and file type should accept only xsl format.