diff --git a/src/lib/components/AssistantSettings.svelte b/src/lib/components/AssistantSettings.svelte
index d99d8b52a27..db973397c0f 100644
--- a/src/lib/components/AssistantSettings.svelte
+++ b/src/lib/components/AssistantSettings.svelte
@@ -50,7 +50,14 @@
function onFilesChange(e: Event) {
const inputEl = e.target as HTMLInputElement;
- if (inputEl.files?.length) {
+ if (inputEl.files?.length && inputEl.files[0].size > 0) {
+ if (!inputEl.files[0].type.includes("image")) {
+ inputEl.files = null;
+ files = null;
+
+ form = { error: true, errors: [{ field: "avatar", message: "Only images are allowed" }] };
+ return;
+ }
files = inputEl.files;
resetErrors();
deleteExistingAvatar = false;
@@ -90,6 +97,10 @@
// else we just remove it from the input
formData.delete("avatar");
}
+ } else {
+ if (files === null) {
+ formData.delete("avatar");
+ }
}
return async ({ result }) => {
@@ -135,7 +146,7 @@
/>
{:else if assistant?.avatar}
@@ -169,8 +180,8 @@
Upload
-
{getError("avatar", form)}
{/if}
+ {getError("avatar", form)}