Skip to content

Instantly share code, notes, and snippets.

@bmcbride
Last active May 25, 2022 17:53
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bmcbride/7577e6aed5ce962776ca to your computer and use it in GitHub Desktop.
Save bmcbride/7577e6aed5ce962776ca to your computer and use it in GitHub Desktop.
Upload image from HTML form to http://imgur.com/
function deleteFromImgur() {
$.ajax({
url: "https://api.imgur.com/3/image/{id}",
type: "DELETE",
headers: {
"Authorization": "Client-ID YOUR-CLIEND-ID-GOES-HERE"
},
success: function(response) {
//console.log(response);
}
});
}
function postToImgur() {
var formData = new FormData();
formData.append("image", $("[name='uploads[]']")[0].files[0]);
$.ajax({
url: "https://api.imgur.com/3/image",
type: "POST",
datatype: "json",
headers: {
"Authorization": "Client-ID YOUR-CLIEND-ID-GOES-HERE"
},
data: formData,
success: function(response) {
//console.log(response);
var photo = response.data.link;
var photo_hash = response.data.deletehash;
},
cache: false,
contentType: false,
processData: false
});
}
@raihan004
Copy link

do you know How can I store those uploaded images or how can I upload them to my own profile?
thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment