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

57
Views
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
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!