null checks for file uploading
This commit is contained in:
parent
8e87635209
commit
46e617c9fb
2 changed files with 30 additions and 16 deletions
|
@ -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"],
|
json.icon ? ["img", this.info.cdn + "/app-icons/" + appId + "/" + json.icon + ".png?size=128", [128, 128]] : ["text", "No icon"],
|
||||||
["fileupload", "Application icon:", event => {
|
["fileupload", "Application icon:", event => {
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.readAsDataURL(event.target.files[0]);
|
const files = event.target.files;
|
||||||
reader.onload = () => {
|
if (files) {
|
||||||
fields.icon = reader.result;
|
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"],
|
fields.avatar ? ["img", fields.avatar, [128, 128]] : ["text", "No avatar"],
|
||||||
["fileupload", "Bot avatar:", event => {
|
["fileupload", "Bot avatar:", event => {
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.readAsDataURL(event.target.files[0]);
|
const files = event.target.files;
|
||||||
reader.onload = () => {
|
if (files) {
|
||||||
fields.avatar = reader.result;
|
const file = files[0];
|
||||||
};
|
reader.readAsDataURL(file);
|
||||||
|
reader.onload = () => {
|
||||||
|
fields.avatar = reader.result;
|
||||||
|
};
|
||||||
|
}
|
||||||
}]
|
}]
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
|
|
@ -1192,10 +1192,13 @@ class Localuser{
|
||||||
json.icon ? ["img", this.info.cdn+"/app-icons/" + appId + "/" + json.icon + ".png?size=128", [128, 128]] : ["text", "No icon"],
|
json.icon ? ["img", this.info.cdn+"/app-icons/" + appId + "/" + json.icon + ".png?size=128", [128, 128]] : ["text", "No icon"],
|
||||||
["fileupload", "Application icon:", event=>{
|
["fileupload", "Application icon:", event=>{
|
||||||
const reader=new FileReader();
|
const reader=new FileReader();
|
||||||
reader.readAsDataURL((event.target as HTMLInputElement).files[0]);
|
const files=(event.target as HTMLInputElement).files;
|
||||||
reader.onload=()=>{
|
if(files){
|
||||||
fields.icon=reader.result;
|
reader.readAsDataURL(files[0]);
|
||||||
};
|
reader.onload=()=>{
|
||||||
|
fields.icon=reader.result;
|
||||||
|
};
|
||||||
|
}
|
||||||
}]
|
}]
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
@ -1280,10 +1283,14 @@ class Localuser{
|
||||||
fields.avatar ? ["img", fields.avatar, [128, 128]] : ["text", "No avatar"],
|
fields.avatar ? ["img", fields.avatar, [128, 128]] : ["text", "No avatar"],
|
||||||
["fileupload", "Bot avatar:", event=>{
|
["fileupload", "Bot avatar:", event=>{
|
||||||
const reader=new FileReader();
|
const reader=new FileReader();
|
||||||
reader.readAsDataURL((event.target as HTMLInputElement).files[0]);
|
const files=(event.target as HTMLInputElement).files;
|
||||||
reader.onload=()=>{
|
if(files){
|
||||||
fields.avatar=reader.result;
|
const file=files[0]
|
||||||
};
|
reader.readAsDataURL(file);
|
||||||
|
reader.onload=()=>{
|
||||||
|
fields.avatar=reader.result;
|
||||||
|
};
|
||||||
|
}
|
||||||
}]
|
}]
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue