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

103
Views
File Input in JavaScript function for Tesseract.js

I have this website in which the User Inputs a file and then then the website returns in the console the text in the image. I use Tesseract.js, and the recognize function which has a file as parameter and string for language. Everything works fine when I put a sample file in manually in the function but want to know how to input a file that the users selects. How do I make the user file input in the recognize function? How do I replace "sample.PNG" with the user selected file?

Tesseract.recognize(
    "sample.PNG","eng",
    { 
      logger: m => console.log(m) 
    }
  )
  .catch (err => {
    console.error(err);
  })
  .then(result => {
   console.log(result);
  })
  
  
<html>
<head>
    <script src='https://unpkg.com/tesseract.js@v2.1.0/dist/tesseract.min.js'></script>
 <script src = "script.js"></script>
</head>
<input type="file" name="file" id="fileInput">
<button id = "">Submit</button>
</html>

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!