From a1d177678c84891e53ceb5f318481b4ed3436cc4 Mon Sep 17 00:00:00 2001 From: waltem01 Date: Fri, 16 Feb 2024 07:16:32 +0100 Subject: [PATCH] save image and url --- Webserver/src/routes/image/+page.svelte | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Webserver/src/routes/image/+page.svelte b/Webserver/src/routes/image/+page.svelte index 9caafd3..1fb12b2 100644 --- a/Webserver/src/routes/image/+page.svelte +++ b/Webserver/src/routes/image/+page.svelte @@ -7,20 +7,25 @@ interval: NodeJS.Timeout; } - let imageURL: string, uploadData: UploadData; + let imageURL: string | null, lastImage: File; + let uploadData: UploadData; async function sendImage() {} function uploadImage(event: Event) { // Revoke previous image url, if any - if (imageURL) URL.revokeObjectURL(imageURL); + if (imageURL) { + URL.revokeObjectURL(imageURL); + imageURL = null; + } // Get user input const input = event.target as HTMLInputElement; const file = input?.files?.[0]; if (!file) return; - // Load image data from file + // Load image data and file + lastImage = file; imageURL = URL.createObjectURL(file); // Time upload by saving date