Community

trouble with upload a png to ocr by javascript

I use XMLHttpRequest to post a png file captured by canvas.
var xhr = new XMLHttpRequest(); xhr.send(canvas.toDataURL('image/png').replace(/^data:image\/(png|jpg);base64,/, ""));

But the server replies me by "551 (Unsupported image file format)"

Was this article helpful?

0 out of 0 found this helpful

Comments

1 comment

  • Avatar
    SDK Support Team

    Are you sure that replace() encodes your png image as base64?

    var data = canvas.toDataURL('image/png');
    data.replace(/^data:image\/(png|jpg);base64,/, "");
    

    Also, it seems you are doing cross-domain XMLHttpRequest from within a browser. Take a look here. If you succeed in your task, let us know so we can add html/javascript sample to our samples repository.

    0

Please sign in to leave a comment.