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

114
Views
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 answers
Answer question

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