Home » Wapka Codes » imgur.com Image Upload Function
![]() |
Api data creator:
Config:
Create page called "api-imgur".
Page type: application/javascript
%notify%<br/><div class="list"><b>Share With : Public</b><br/><textarea name="msg" id="comment-comment"></textarea><br/><input type="submit" value="Post"/><a id="upload">[ <i class="fa fa-upload" aria-hidden="true"></i> ]</a></div><input style="display:none" type="file" id="f" accept="image/*">
<script src="/api-imgur"></script>
<script>
document.querySelector("#upload").onclick = function() {
document.querySelector("#f").click();}
imgur("#f",{loading : function(load) {document.querySelector("#upload").innerHTML = '[ <i class="fa fa-upload" aria-hidden="true"></i> Upload pictures '+load+' ]'},
loaded : function(link,size,type,time) {
var input = $("textarea#comment-comment").val();
$("textarea#comment-comment").val(input+"
");
$("#upload").html('[ <i class="fa fa-upload" aria-hidden="true"></i>]');}})
</script>
Config:
<pid>65675</pid><category>post</category>
<value1>:POST(msg);</value1>
Create page called "api-imgur".
Page type: application/javascript
function imgur(f,ob){var files=document.querySelector(f);files.onchange=function(){var file=this.files[0];if(file&&file.type.match(/image.*/)){var fd=new FormData();fd.append("image",file);var xhr=new XMLHttpRequest();xhr.open("POST","https://api.imgur.com/3/image.json");xhr.upload.onprogress=function(e){if(e.lengthComputable){var percent=Math.floor((e.loaded/e.total)*100)+'%';ob.loading(percent)}};xhr.onload=function(){var imgs;var res=JSON.parse(xhr.responseText);if(res.status===200&&res.success===!0){var data=res.data;ob.loaded(data.link,data.type,data.size,data.datetime)}else{window.alert('Error: Upload failed')}}
xhr.setRequestHeader('Authorization','Client-ID b558035630d26ef');xhr.send(fd)}else{window.alert('Only picture options allowed')}}}
Recent Comments
![]() |
https://mobile.wapka.co/view/49620?q=how-to-set-category-on-api-data&id=49620&uid=65014
![]() |
How to set pid in this function