Image to text OCR web image URL upload
P粉316890884
P粉316890884 2024-03-29 21:37:25
0
1
346

Referring to the work here codepen demo, if click the select file button to upload an image from the local computer and extract the text from the image, the application runs fine. But how do I upload a web image URL like this, instead of from a local computer file, and output the OCR text results with the help of the button I marked in the demo?

If I can get any help I would be grateful :)

<div class="Content extra"><input id="File" type="File" onchange="proccess(window.lastFile=this.files[0])">< ;/div>

I tried changing onchange to onclick but it didn't work.

P粉316890884
P粉316890884

reply all(1)
P粉491421413

You can add input like this:

And check your process function, if the parameter is a string, if it is, it means we have a URL, so we just define this url as the src value:

function proccess(inputData){
  $(".result").html("");
  var src;
  if(typeof(inputData) == 'string') {
    src = inputData
  } else {
    src = (window.URL ? URL : webkitURL).createObjectURL(inputData);
  }
  //do what you want after that...
  //...
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!