Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

341
Vistas
how to accept only apk file in react js?
import React from "react";
export default function DropDown() {
  const changeHandler=()=>{
    let value=document.getElementById('someId');
    let ext = value.match(/\.([^\.]+)$/)[1];
    switch (ext) {
      case 'apk':
        alert('Allowed');
        break;
      default:
        alert('Not allowed');
        value = '';
    }
  };
return (
    <>
     <input type="file" id="someId" accept=".apk" onChange={changeHandler} />
    </>
  );
}

after selecting file it throws error value.match is not a function. how to resolve that if we click upload button if we upload apk file popup throws allow or else popup is not allowed

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The accept=".apk" prop in the first place if it is supported by the browser would not allow non .apk files.

If you really want to get the actual filename with the extension, the event handler itself passes an event object. You just need to access the target of that event in your change handler.

const changeHandler=(e)=>{
  const filename = e.target.files[0].name; // filename.apk
  // do whatever you want.
}

you may also use e.target.files[0].type will also show what filename type was chosen.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda