I am trying to submit an Post Request to an image recognition API using Javascript, but I cannot work out how to send the actual image. I know that I cannot send it just using a local file (I get the "Cross origin requests are only supported for protocol schemes" error when I try to run it). How would I send the image using a Post request?
My code so far is:
var xhr = new XMLHttpRequest();
xhr.open("POST", "cigarette.jpg", false);
xhr.setRequestHeader("Authorization", "CloudSight [key]");
xhr.send("http://api.cloudsightapi.com/image_requests");
console.log(xhr.status);
console.log(xhr.statusText);
I am quite new to Javascript and APIs and haven't really done anything like this before; how would I send the image without going into incredibly complicated stuff?