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

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

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 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