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

79
Views
Reading data from object in javascript

I want to transfer the images selected by the user to an object with javascript and read from there. I do this using the code below. When I print the productImages variable to the console, the data appears, but what should I do to read the data one by one?


let productImages = {};
var totalfiles = document.getElementById('uploadImages').files.length;
let x = 0;
for (var index = 0; index < totalfiles; index++) {
    var file = document.getElementById('uploadImages').files[index];
    if (file) {
        var reader = new FileReader();
        reader.readAsDataURL(file);
        reader.onload = async function(e) {
            Image = e.target.result;
            productImages[x] = {'data': {'image': Image}};
            x++;
        };
    }
}
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Try this way, to ready your productImages object

for (const image in productImages) {
  console.log(productImages[image].data);
}
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!