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

252
Views
¿Cómo cargar 1 imagen + convertir a base64 + mostrar la misma imagen con la misma ID varias veces en la misma página HTML con javascript?

Funciona bien pero solo muestra la imagen una vez... Gracias por su ayuda

 <input type="file" id="file-upload" class="upload-file bg-highlight shadow-s rounded-s " accept="image/*"> <img id="image-data" src="images/empty.png" class="img-fluid"> <img id="image-data" src="images/empty.png" class="img-fluid"> <img id="image-data" src="images/empty.png" class="img-fluid"> <img id="image-data" src="images/empty.png" class="img-fluid">

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Esto podría funcionar como se esperaba. Elija un archivo de imagen y use FileReader para leer datos de imagen.

 document.getElementById('file-upload').addEventListener('change', e => { const file = e.target.files[0]; const reader = new FileReader(); reader.addEventListener("load", function () { document.querySelectorAll('#image-data').forEach(i => i.src = reader.result); }); if (file) { reader.readAsDataURL(file); } });
 #image-data { width: 100px; height: 100px; }
 <input type="file" id="file-upload" class="upload-file bg-highlight shadow-s rounded-s " accept="image/*"> <img id="image-data" src="images/empty.png" class="img-fluid"> <img id="image-data" src="images/empty.png" class="img-fluid"> <img id="image-data" src="images/empty.png" class="img-fluid"> <img id="image-data" src="images/empty.png" class="img-fluid">

about 4 years ago · Juan Pablo Isaza 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!