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

203
Views
Uploading File doesn't let me pick same file after I remove it from selection in react

in react when we clear the file by clicking cross button we are not able to select the same file. How to write the function that after removing existing file if user again want to pick the same file file should not be selected .If you want to select rather than existing file then file should be selected.

  import React from "react";
export default function DropDown() {
const [checked, setChecked] = React.useState(false);
function fun(e)
{
  let file=e.target.files[0];
  localStorage.setItem("selectedFile",file.name);
  if (localStorage.getItem("selectedFile")===file.name) 
  {
    alert('duplicate');
   // document.getElementById("file").value = '';
  //setChecked(false);
  } 
  else 
  {
    alert('not duplicate');
    //setChecked(true);
  }
  console.log(localStorage.selectedFile);
}
return (
    <div >
     <input type="file"  id="file" onChange={(e) => {setChecked(true);fun(e)}} />
    {checked ?<button onClick={(e)=>{setChecked(false);document.getElementById("file").value = '';}}>x</button>:null}
    </div>
  );
}
about 4 years ago · Juan Pablo Isaza
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!