I've been looking at similar questions on here and done lots of Googling but nothing is exactly correct to how I need it.
I need to have a script that when the javascript is called, it will take you to a direct jpg location on the web server and POST it to an external server. I have the servers POST receiving files fine and I actually have some code that POSTs a variable okay. I just really need the image 'get' The example:
- User goes to page with javascript included
- script grabs jpg from set location E.G /img/coolphoto.jpg
- Post image to external server
I've played with XMLHTTPRequest to get the jpg, but I am not having great luck. I've tried converting to BASE64 and all sorts, but I guess I am doing things slightly wrong.
Could anyone give a hand? Thanks
UPDATE:
function httpGet(theUrl)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", theUrl, false ); // false for synchronous request
xmlHttp.send( null );
return xmlHttp.responseText;
}
So this is the code I am using to grab the image, I really just need this to grab it, base64 it so I can POST the BASE64 to my server, and then decode on the server to get the jpg