diff --git a/app/routes/report.tsx b/app/routes/report.tsx index 6a19a88..2e6c1ef 100644 --- a/app/routes/report.tsx +++ b/app/routes/report.tsx @@ -168,11 +168,6 @@ export default function () { setUploading(true); - const increaseProgress = (e: ProgressEvent) => { - bytesRead += e.loaded; - setFileProgress(Math.floor((bytesRead / totalSize) * 100)); - }; - for (let i = 0; i < upload_urls.length; i++) { await new Promise((resolve) => { const xhr = new XMLHttpRequest(); @@ -186,7 +181,12 @@ export default function () { fileTypes[files[i].name.split(".").at(-1) as string], ); - xhr.upload.addEventListener("progress", increaseProgress); + xhr.upload.onprogress = (e) => { + if (!e.lengthComputable) return; + + bytesRead += e.loaded; + setFileProgress(Math.floor((bytesRead / totalSize) * 100)); + }; xhr.upload.onabort = () => { shouldRecall = true; setUploading(false);