Closed phukol closed 4 years ago
You may try the following code snippet:
async function handleImageUpload(event) {
const imageFiles = Array.from(event.target.files);
const options = {
maxSizeMB: 1,
maxWidthOrHeight: 1920,
useWebWorker: true
}
try {
const compressedFiles = await Promise.all(
imageFiles.map(imageFile => await imageCompression(imageFile, options))
)
await uploadToServer(compressedFiles); // write your own logic
} catch (error) {
console.log(error);
}
}
Thanks for this wonderful library. Just want to ask if how I can use it for a file input with multiple images attached? Thank you.