function sendFile(file) {
var uri = '/saveImage';
var xhr = new XMLHttpRequest();
var fd = new FormData();
xhr.open('POST', uri, true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200) {
var imageName = xhr.responseText;
//do what you want with the image name returned
//e.g update the interface
}
};
fd.append('myFile', file);
xhr.send(fd);
}