Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

340
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!