Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

58
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda