diff --git a/Webserver/src/routes/image/+page.svelte b/Webserver/src/routes/image/+page.svelte index 8663162..d93f40d 100644 --- a/Webserver/src/routes/image/+page.svelte +++ b/Webserver/src/routes/image/+page.svelte @@ -22,7 +22,7 @@ h: number; } - let imageURL: string | null, lastImage: File; + let imageURL: string | null; let uploadData: UploadData, matrix: Matrix; let uploadStarted = false, submitData: SubmitData; @@ -59,7 +59,7 @@ if (!mdata.success) alert(`Error while processing '${endpoint}'!`); } - async function fileAsDataURL(file: File, data: SubmitData): Promise { + async function fileAsDataURL(data: SubmitData): Promise { return new Promise((resolve, reject) => { const img = new Image(); img.onload = () => { @@ -79,9 +79,8 @@ }; img.onerror = reject; - // Create an object URL for the file and set it as the image source - const objectURL = URL.createObjectURL(file); - img.src = objectURL; + // Load image by assigning url + img.src = imageURL!; }); } @@ -98,8 +97,7 @@ const file = input?.files?.[0]; if (!file) return; - // Load image data and file - lastImage = file; + // Load image data from file imageURL = URL.createObjectURL(file); } @@ -222,8 +220,9 @@ User uploaded {/if} + {#if uploadStarted} - {#await fileAsDataURL(lastImage, submitData)} + {#await fileAsDataURL(submitData)}

Loading image data . . .

{uploadData.elapsed} seconds elapsed.

{:then dataUrl}