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

138
Views
Is there a way in JS / React to execute code if input[type="file"] has a file uploaded

i want to execute some code only if user has clicked on "add file" (when we use an input type file in html) and selected a file. Is there a way to do this ?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Yes, you can work with the input event like this:

const input = document.querySelector('input');

input.addEventListener('input', updateValue);

function updateValue(e) {
  log.textContent = e.target.value;
}

You can of course modify this to suit your requirement. This example is from the Mozilla documentation here

Take a look at this answer which you may also find useful. It works with the change event.

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!