help How to add an avatar
Posted: Fri Oct 06, 2023 8:17 am
I don't understand how to add an avatar to a profile, please help me
Code: Select all
<img src="{{VALUE(%avatar%)@OR(https://img.wapka.org/000ans.jpg)}}"/>
Code: Select all
<id>{{GET(id)}}</id>
Code: Select all
<div class="aside" style="text-decoration:none">
<a id="upload">
<img src="https://cdn.wapka.org/008gzn/0ea909af1a01f6a437b63d7e50148208/upload-gb19933c89_640.png" height="30" width="30"/> <br/>
Trocar foto de perfil!
</a><br/>
<input style="display:none" name="avatar" value="%avatar%" id="loadavt" type="text" readonly>
<input style="display:none" type="file" id="f" accept="image/*">
</div>
Code: Select all
<USERID>{{VAR(USER_ID)}}</USERID>
<SET_AVATAR>{{POST(avatar)}}</SET_AVATAR>
Code: Select all
<script>function imgur(e,a){document.querySelector(e).onchange=function(){var e=this.files[0];if(e&&e.type.match(/image.*/)){var t=new FormData;t.append("image",e);var n=new XMLHttpRequest;n.open("POST","https://api.imgur.com/3/image.json"),n.upload.onprogress=function(e){if(e.lengthComputable){var t=Math.floor(e.loaded/e.total*100)+"%";a.loading(t)}},n.onload=function(){var e=JSON.parse(n.responseText);if(200===e.status&&!0===e.success){var t=e.data;a.loaded(t.link,t.type,t.size,t.datetime)}else window.alert("Lỗi: tải lên thất bại")},n.setRequestHeader("Authorization","Client-ID aacca020023959a"),n.send(t)}else window.alert("Chỉ cho phép chọn ảnh")}}document.querySelector("#upload").onclick=function(){document.querySelector("#f").click()},imgur("#f",{loading:function(e){document.querySelector("#upload").innerHTML='Tudo deu certo!'+e+" <br/>"},loaded:function(e,a,t,n){var o=$("input#loadavt").val();$("input#loadavt").val(e),document.querySelector("#upload").innerHTML='Upload feito!<br/>Agora salve.'}});</script>