diff --git a/Webserver/src/routes/image/+page.svelte b/Webserver/src/routes/image/+page.svelte index 4804429..0f28724 100644 --- a/Webserver/src/routes/image/+page.svelte +++ b/Webserver/src/routes/image/+page.svelte @@ -16,6 +16,20 @@ await post(fdata, 'upload'); } + async function post(fdata: FormData, endpoint: string) { + // Append endpoint to formdata for redirection + fdata.append('endpoint', endpoint); + // Send request to be redirected to given endpoint + const response = await fetch('/api/redirect', { + method: 'POST', + body: fdata + }); + // Await respose from webserver + const mdata = (await response.json()) as APIResponse; + // Basic error handling + if (!mdata.success) alert(`Error while processing '${endpoint}'!`); + } + async function fileAsDataURL(file: File, width: number, height: number): Promise { return new Promise((resolve, reject) => { const img = new Image();