From 8f4e669d51df73fd0fb3db13bb154bc28c99e24d Mon Sep 17 00:00:00 2001 From: waltem01 Date: Fri, 16 Feb 2024 07:21:03 +0100 Subject: [PATCH] send data url to server --- Webserver/src/routes/image/+page.svelte | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Webserver/src/routes/image/+page.svelte b/Webserver/src/routes/image/+page.svelte index 24d5f32..4804429 100644 --- a/Webserver/src/routes/image/+page.svelte +++ b/Webserver/src/routes/image/+page.svelte @@ -10,6 +10,12 @@ let imageURL: string | null, lastImage: File; let uploadData: UploadData; + async function sendImage(url: string) { + const fdata = new FormData(); + fdata.append('url', url); + await post(fdata, 'upload'); + } + async function fileAsDataURL(file: File, width: number, height: number): Promise { return new Promise((resolve, reject) => { const img = new Image(); @@ -73,8 +79,13 @@ {#await fileAsDataURL(lastImage, 192, 192)}

Loading image data . . .

{uploadData.elapsed} seconds elapsed.

- {:then} -

Done!

-

{uploadData.elapsed} seconds elapsed.

+ {:then dataUrl} + {#await sendImage(dataUrl)} +

Sending image . . .

+

{uploadData.elapsed} seconds elapsed.

+ {:then} +

Done!

+

{uploadData.elapsed} seconds elapsed.

+ {/await} {/await} {/if}