Add file input handling and image type validation in app.js

This commit is contained in:
TristanEDU 2025-09-09 12:40:03 +00:00
parent a84ce27473
commit b85cfe3e34

View File

@ -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);
}
}
};