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

134
Views
Variable that becomes undefined in an onload

I am distributing my images converted to base64 and then crop them, but when I run the function my variablechosenImage, she goes undefined in the onload but is well defined just before (observation made thanks to the debugger). Would you have a solution to solve my problem? I've already tried passing the variable to var to make it global, but no effect. Here is my code :

let reader = new FileReader();
let uploadButton = document.getElementById("upload-button");
file_recup = document.getElementById("upload-button").value;
var chosenImage = document.getElementById("img_crop_1");
reader.readAsDataURL(uploadButton.files[0]);
reader.onload = () => {
   chosenImage.src = reader.result;  
}
about 4 years ago · Santiago Gelvez
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!