forked from open-webui/open-webui
Merge pull request #1644 from Entaigner/patch-6
Bugfix: FileReader can't be reused so init one per image
This commit is contained in:
commit
e82d9c873b
1 changed files with 22 additions and 25 deletions
|
@ -316,8 +316,13 @@
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
|
||||||
if (e.dataTransfer?.files) {
|
if (e.dataTransfer?.files) {
|
||||||
let reader = new FileReader();
|
const inputFiles = Array.from(e.dataTransfer?.files);
|
||||||
|
|
||||||
|
if (inputFiles && inputFiles.length > 0) {
|
||||||
|
inputFiles.forEach((file) => {
|
||||||
|
console.log(file, file.name.split('.').at(-1));
|
||||||
|
if (['image/gif', 'image/jpeg', 'image/png'].includes(file['type'])) {
|
||||||
|
let reader = new FileReader();
|
||||||
reader.onload = (event) => {
|
reader.onload = (event) => {
|
||||||
files = [
|
files = [
|
||||||
...files,
|
...files,
|
||||||
|
@ -327,13 +332,6 @@
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
const inputFiles = Array.from(e.dataTransfer?.files);
|
|
||||||
|
|
||||||
if (inputFiles && inputFiles.length > 0) {
|
|
||||||
inputFiles.forEach((file) => {
|
|
||||||
console.log(file, file.name.split('.').at(-1));
|
|
||||||
if (['image/gif', 'image/jpeg', 'image/png'].includes(file['type'])) {
|
|
||||||
reader.readAsDataURL(file);
|
reader.readAsDataURL(file);
|
||||||
} else if (
|
} else if (
|
||||||
SUPPORTED_FILE_TYPE.includes(file['type']) ||
|
SUPPORTED_FILE_TYPE.includes(file['type']) ||
|
||||||
|
@ -470,6 +468,10 @@
|
||||||
hidden
|
hidden
|
||||||
multiple
|
multiple
|
||||||
on:change={async () => {
|
on:change={async () => {
|
||||||
|
if (inputFiles && inputFiles.length > 0) {
|
||||||
|
const _inputFiles = Array.from(inputFiles);
|
||||||
|
_inputFiles.forEach((file) => {
|
||||||
|
if (['image/gif', 'image/jpeg', 'image/png'].includes(file['type'])) {
|
||||||
let reader = new FileReader();
|
let reader = new FileReader();
|
||||||
reader.onload = (event) => {
|
reader.onload = (event) => {
|
||||||
files = [
|
files = [
|
||||||
|
@ -482,11 +484,6 @@
|
||||||
inputFiles = null;
|
inputFiles = null;
|
||||||
filesInputElement.value = '';
|
filesInputElement.value = '';
|
||||||
};
|
};
|
||||||
|
|
||||||
if (inputFiles && inputFiles.length > 0) {
|
|
||||||
const _inputFiles = Array.from(inputFiles);
|
|
||||||
_inputFiles.forEach((file) => {
|
|
||||||
if (['image/gif', 'image/jpeg', 'image/png'].includes(file['type'])) {
|
|
||||||
reader.readAsDataURL(file);
|
reader.readAsDataURL(file);
|
||||||
} else if (
|
} else if (
|
||||||
SUPPORTED_FILE_TYPE.includes(file['type']) ||
|
SUPPORTED_FILE_TYPE.includes(file['type']) ||
|
||||||
|
|
Loading…
Reference in a new issue