¿Necesito cargar un archivo que acepte archivos XLS solo con un límite de tamaño de archivo de 5mb Angular 13?
HTML
<input name="file" type="file" (change)="onSelectFile($event)" required/> <button type ="file"> </button>
archivo ts
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; } }aquí solo puedo recibir un mensaje de advertencia sobre el límite de tamaño, no sobre el tipo de archivo
Necesito que ambas validaciones sucedan.
también probado de esta manera:
if (this.file.size >5000 * 1024) { this.warning = true; } else if (this.files.type !== allowed_type){ this.warning = true; }else{ this.warning = false; }Aquí no debería permitir más de 5 MB y el tipo de archivo debería aceptar solo el formato xsl.