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

155
Views
Why is image uploader not working on chrome?

I have a button where you can upload an image and insert it in a tag, it works on every browser but not on chrome. The first reader.onloadend is processed, I can log image and image.src.

var inputUpload = document.getElementById('buttonUpload');

inputUpload.addEventListener('change', (e) => {
  const file = e.target.files[0];
  const reader = new FileReader();

  reader.onloadend = () => {
  //Initiate the JavaScript Image object.
  var image = new Image();

  image.src = reader.result;
  console.log('image.src');

  image.onloadend = function() { /* execution stops here */
    var height = this.height;
    var width = this.width;
    if (height > 150 || width > 150) {
      showAlert('Image dimensions must be within 150×150 pixels.');
    } else {
      // convert file to base64 String
      const base64String = reader.result.replace('data:', '').replace(/^.+,/, '');
      // display image
      valueImg = "data:image/png;base64," + base64String;
      updateImg(valueImg);
    };
  };
};
reader.readAsDataURL(file);
});
<button id="buttonUpload" type="button" class="d-inline btn-custom mx-0">
     Upload
</button>

    

When I select the image file, it stops at image.loadend but I get no errors in the console

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!