null checks for file uploading

This commit is contained in:
MathMan05 2024-09-09 10:57:57 -05:00
parent 8e87635209
commit 46e617c9fb
2 changed files with 30 additions and 16 deletions

View file

@ -1193,10 +1193,13 @@ class Localuser {
json.icon ? ["img", this.info.cdn + "/app-icons/" + appId + "/" + json.icon + ".png?size=128", [128, 128]] : ["text", "No icon"],
["fileupload", "Application icon:", event => {
const reader = new FileReader();
reader.readAsDataURL(event.target.files[0]);
reader.onload = () => {
fields.icon = reader.result;
};
const files = event.target.files;
if (files) {
reader.readAsDataURL(files[0]);
reader.onload = () => {
fields.icon = reader.result;
};
}
}]
]
],
@ -1278,10 +1281,14 @@ class Localuser {
fields.avatar ? ["img", fields.avatar, [128, 128]] : ["text", "No avatar"],
["fileupload", "Bot avatar:", event => {
const reader = new FileReader();
reader.readAsDataURL(event.target.files[0]);
reader.onload = () => {
fields.avatar = reader.result;
};
const files = event.target.files;
if (files) {
const file = files[0];
reader.readAsDataURL(file);
reader.onload = () => {
fields.avatar = reader.result;
};
}
}]
]
],