Add file input handling and image type validation in app.js
This commit is contained in:
parent
a84ce27473
commit
b85cfe3e34
20
src/app.js
20
src/app.js
@ -3,6 +3,15 @@ const imagePreview = document.getElementById("imagePreview");
|
||||
const textEditor = document.getElementById("textEditor");
|
||||
const ocrButton = document.getElementById("btnRunOCR");
|
||||
const exportButton = document.getElementById("btnExport");
|
||||
const imageTypes = [
|
||||
"image/jpeg",
|
||||
"image/png",
|
||||
"image/gif",
|
||||
"image/bmp",
|
||||
"image/webp",
|
||||
"image/svg+xml",
|
||||
"image/tiff",
|
||||
];
|
||||
|
||||
console.log(
|
||||
"DOM wired:",
|
||||
@ -12,3 +21,14 @@ console.log(
|
||||
ocrButton,
|
||||
exportButton
|
||||
);
|
||||
|
||||
fileInput.onchange = () => {
|
||||
const selectedFiles = [...fileInput.files];
|
||||
for (const f of selectedFiles) {
|
||||
console.log(f);
|
||||
if (imageTypes.includes(f.type)) {
|
||||
console.log("Image Type = " + f.type);
|
||||
imagePreview.src = URL.createObjectURL(f);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user