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

319
Views
El archivo se carga a pesar de que se establece el límite, la entrada no se vacía

Probablemente me estoy perdiendo algo obvio, pero una vez que confirmo que está bien en la window.alert de ventana, el nombre del archivo todavía aparece junto a Choose File . Así que se está subiendo a la entrada todavía. ¿Cómo evito esto?

 <input id="uploadFile" type="file" onChange={chooseFile} />
 const chooseFile = (e) => { e.preventDefault() const file = e.target.files[0] if (file.size > 2e6) { window.alert("Please upload a file smaller than 2 MB") e.target.file = "" return false } }
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Vacíe la propiedad de value de la input . Para eso, cambie e.target.file = "" a e.target.value = "" . Aquí está el código de su agujero:

 const chooseFile = (e) => { e.preventDefault() const file = e.target.files[0] if (file.size > 2e6) { window.alert("Please upload a file smaller than 2 MB") e.target.value = "" return false } }
about 4 years ago · Santiago Trujillo 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!