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

61
Vistas
Read static / public image blob of my website

TL;DR: On my website, I have a file name of a static file, and I need a Blob or byte array.

I assume it's been asked before as it's pretty basic, but I've spent 2 hours on this already and all the questions involve an <input> element / events / DOM elements, and I just want to read files I have already as the site is built.


I'm trying to quickly make a local website with a few images and a button, that should fire an API call when pressed, with the images attached to it.

The site is built using the most basic express app I could find. I simply ran npx express-generator --no-view to get the simplest HTML template. For all intent's and purposes, everything happens in one file - index.html.

I want the files converted to byte streams, blobs, or anything that I could work with. Now, I have images inside public folder of the app. Assuming I know the filenames and can access them in index.html / <script>, how can I go from a filename to a Blob, byte string or anything like that?

Illustration in code:

img1_fname = "/images/img1.png"
img2_fname = "/images/img2.png"
...
imgN_fname = "/images/imgN.png"

// Question
img1_bytes = ???
img2_bytes = ???
...
imgN_bytes = ???

var formData = new FormData();
formData.append(img1_fname, img1_bytes);
formData.append(img2_fname, img2_bytes);
...
formData.append(imgN_fname, imgN_bytes);

var request = new XMLHttpRequest();
request.open("POST", URL);
request.send(formData);
about 4 years ago · Juan Pablo Isaza
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