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

116
Vistas
Upload camera image to server with JavaScript

I am coding a webpage where the user can take a photo with his phone camera, then the image will be processed and stored in the server.

I am storing the image content on a <canvas> an showing it with <img> tag but I don't know how to send that information to the server.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I just solved it by converting the canvas content into a blob and sending it to the server with fetch:

Canvas to blob

someButton.onclick = (e) => {
   //some previous code
    canvas.toBlob(upload)
}

Upload Function

function upload(blob) {
    const form = new FormData();
    form.append("img_name",blob)
    fetch("/path/to/api", {
        method:'POST',
        body:form,
    }, ).then(res => res.text()).then(resp => console.log(resp))
}

Then the server treats the file as needed.

about 4 years ago · Juan Pablo Isaza 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