Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

344
Visualizações
upload file should accepts XLS files only file size limit 5mb Angular 13

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.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda