From 60fd19cb17e08217fc83efe0b02eaedff6444baa Mon Sep 17 00:00:00 2001 From: waltem01 Date: Thu, 15 Feb 2024 08:18:22 +0100 Subject: [PATCH] handle loading image from url --- Webserver/src/routes/image/+page.svelte | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Webserver/src/routes/image/+page.svelte b/Webserver/src/routes/image/+page.svelte index 0a4717a..cadd518 100644 --- a/Webserver/src/routes/image/+page.svelte +++ b/Webserver/src/routes/image/+page.svelte @@ -13,7 +13,18 @@ async function loadImage(url: string): Promise {} - function uploadImage(event: Event) {} + function uploadImage(event: Event) { + // Revoke previous image url, if any + if (imageURL) URL.revokeObjectURL(imageURL); + + // Get user input + const input = event.target as HTMLInputElement; + const file = input?.files?.[0]; + if (!file) return; + + // Load image data from file + imageURL = URL.createObjectURL(file); + }