Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

253
Vistas
How to upload 1 image + convert to base64 + display the same image with the same ID multiple times on the same HTML page with javascript?

It works well but only display the image one time... Thank you for your help

<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 Respuestas
Responde la pregunta

0

This could work as expected. Choose an image file and use FileReader to read image data.

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda