<html>
<head>
<script>
var client = new XMLHttpRequest();
function upload()
{
var file = document.getElementById("file");
// working var formData = { image: "
https://www.google.com/images/srpr/logo11w.png"};
var formData = new FormData();
formData.append("image", file.files[0]); // This is not working??
client.open("POST", "
https://api.imgur.com/3/upload", true);
client.setRequestHeader("Authorization", "Client-ID xxx");
client.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
client.send(JSON.stringify(formData));
}
client.onreadystatechange = function()
{
if (client.readyState == 4 && client.status == 200)
{
document.write(client.responseText);
}
}
</script>
</head>
<body>
<input type="file" id="file" name="file" />
<input type="button" value="upload" onclick="upload()" />
</body>
</html>