diff options
Diffstat (limited to 'resources/assets/js/profile.js')
-rw-r--r-- | resources/assets/js/profile.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/resources/assets/js/profile.js b/resources/assets/js/profile.js index bce94da..d834542 100644 --- a/resources/assets/js/profile.js +++ b/resources/assets/js/profile.js @@ -10,4 +10,30 @@ $("#avatarFile").on("change", () => { if (file) { reader.readAsDataURL(file); } +}); + +$("#avatarForm").submit(function (e) { + var url = "/avatar"; + var data = new FormData(); + $.each(jQuery('#avatarFile')[0].files, (i, file) => { + data.append('avatar', file); + }); + + e.preventDefault(); + $.ajax({ + url: url, + data: data, + cache: false, + contentType: false, + processData: false, + method: 'POST', + type: 'POST', + success: (data) => { + $("#avatarUploadSucceededAlert").show(); + $("#avatarUploadSucceededMessage").text(data.success); + }, + error: () => { + $("#avatarUploadFailedAlert").show(); + } + }); });
\ No newline at end of file |