forked from open-webui/open-webui
feat: bulk document upload
This commit is contained in:
parent
7f3ba3d2ac
commit
0682a4a361
1 changed files with 27 additions and 25 deletions
|
@ -89,11 +89,9 @@
|
|||
const inputFiles = e.dataTransfer?.files;
|
||||
|
||||
if (inputFiles && inputFiles.length > 0) {
|
||||
const file = inputFiles[0];
|
||||
for (const file of inputFiles) {
|
||||
console.log(file, file.name.split('.').at(-1));
|
||||
if (['image/gif', 'image/jpeg', 'image/png'].includes(file['type'])) {
|
||||
reader.readAsDataURL(file);
|
||||
} else if (
|
||||
if (
|
||||
SUPPORTED_FILE_TYPE.includes(file['type']) ||
|
||||
SUPPORTED_FILE_EXTENSIONS.includes(file.name.split('.').at(-1))
|
||||
) {
|
||||
|
@ -104,6 +102,7 @@
|
|||
);
|
||||
uploadDoc(file);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
toast.error(`File not found.`);
|
||||
}
|
||||
|
@ -153,10 +152,12 @@
|
|||
id="upload-doc-input"
|
||||
bind:files={inputFiles}
|
||||
type="file"
|
||||
multiple
|
||||
hidden
|
||||
on:change={async (e) => {
|
||||
if (inputFiles && inputFiles.length > 0) {
|
||||
const file = inputFiles[0];
|
||||
for (const file of inputFiles) {
|
||||
console.log(file, file.name.split('.').at(-1));
|
||||
if (
|
||||
SUPPORTED_FILE_TYPE.includes(file['type']) ||
|
||||
SUPPORTED_FILE_EXTENSIONS.includes(file.name.split('.').at(-1))
|
||||
|
@ -168,6 +169,7 @@
|
|||
);
|
||||
uploadDoc(file);
|
||||
}
|
||||
}
|
||||
|
||||
inputFiles = null;
|
||||
e.target.value = '';
|
||||
|
|
Loading…
Reference in a new issue