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

461
Views
Converting to base64 returns a very short string (too short)

I'm submitting a form that contains sometimes single, sometimes multiple images. However when I submit an image, say 1.jpg, the console output from my node server is MS5qcGc=. I assume that somehow the image isn't being sent through, only the text? How can I send through the entire image, and convert it to base64?

Client

<form method="post">
    <div class="form-group">
        <label for="imgs">Images</label><input accept="image/*" multiple name="imgs" type="file">
    </div>
</form>

Server

if (typeof req.body.imgs == "string") {
  console.log(new Buffer(req.body.imgs).toString('base64'));
} else {
  for ( i in req.body.imgs) {
    console.log(new Buffer(req.body.imgs[i]).toString('base64'));
  }
}
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You need to add the enctype attribute with a value of multipart/form-data to your form element.

<form method="post" enctype="multipart/form-data">
    <div class="form-group">
        <label for="imgs">Images</label><input accept="image/*" multiple name="imgs" type="file">
    </div>
</form>
over 4 years ago · Santiago Trujillo 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!