akf-forum/themes/default/avatar_upload.ejs

32 lines
795 B
Text
Raw Normal View History

2022-09-09 16:29:36 +03:00
<!DOCTYPE html>
<html lang="en">
<%- include("extra/meta", {title: "Avatar Upload Panel!" }) %>
<body style="text-align: center;">
<%- include("extra/navbar") %>
<h1>Upload avatar for <%= member.name %></h1>
<form>
<input type="file" name="avatar" /><br>
<input class="btn-primary" type="submit" value="Upload" />
</form>
<script>
const form = document.querySelector('form');
form.addEventListener('submit', async e => {
e.preventDefault();
const res = await fetch('/api/users/<%= member.id %>/', {
method: 'PUT',
body: new FormData(form)
})
if (res.error) return alert(res.error);
alert('Success!');
location.href = "/users/<%= member.id %>"
});
</script>
2022-09-17 00:51:52 +03:00
<%- include("extra/footer") %>
2022-09-09 16:29:36 +03:00
</body>
</html>