Skip to content

Instantly share code, notes, and snippets.

@pmav
Created July 6, 2013 23:48
Show Gist options
  • Save pmav/5941693 to your computer and use it in GitHub Desktop.
Save pmav/5941693 to your computer and use it in GitHub Desktop.
Uploading to imgur API from Javascript canvas
function upload() {
var img = document.getElementById("avatar").toDataURL("image/png").split(',')[1];
$.ajax({
url: 'https://api.imgur.com/3/image',
type: 'POST',
headers: { "Authorization": "Client-ID ***YOUR CLIENT ID***" },
dataType: 'json',
data: {
image: img
},
success: function (response) {
console.log(response);
},
error: function (response) {
console.log(response);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment