aboutsummaryrefslogtreecommitdiff
path: root/_www/functions.js
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2024-04-24 13:15:57 +0700
committerShulhan <ms@kilabit.info>2024-04-24 15:05:32 +0700
commit9e7d6accdee5e0620bd9605d0cb225444671e1ce (patch)
tree2625255379b1b492e6622be73ccb97d1950ab9cc /_www/functions.js
parent6f26bfad43f5ea6655aabeb187f2b006be9cf819 (diff)
downloadgorankusu-9e7d6accdee5e0620bd9605d0cb225444671e1ce.tar.xz
_www: fix form input type file where content is binary
If the file in FormInput is binary, the conversion to "FormInput.value" will fail with an error like "invalid characters in String".
Diffstat (limited to '_www/functions.js')
-rw-r--r--_www/functions.js8
1 files changed, 4 insertions, 4 deletions
diff --git a/_www/functions.js b/_www/functions.js
index c2e0ec6..bec94c9 100644
--- a/_www/functions.js
+++ b/_www/functions.js
@@ -29,12 +29,12 @@ export function generateFormInput(parent, fi) {
fi.filemodms = file.lastModified;
fi.value = "";
reader = new FileReader();
- reader.onload = (e) => {
- if (e) {
- fi.value = btoa(reader.result);
+ reader.onload = (ev) => {
+ if (ev && ev.target) {
+ fi.value = reader.result;
}
};
- reader.readAsText(file);
+ reader.readAsBinaryString(file);
};
parent.appendChild(wuiInputFile.element());
break;