prepare sending image to server

This commit is contained in:
waltem01 2024-02-15 08:28:08 +01:00
parent 60fd19cb17
commit f9d2d9fd72

View File

@ -9,9 +9,7 @@
let imageURL: string, uploadData: UploadData; let imageURL: string, uploadData: UploadData;
async function sendImage(data: ImageData) {} async function sendImage() {}
async function loadImage(url: string): Promise<ImageData> {}
function uploadImage(event: Event) { function uploadImage(event: Event) {
// Revoke previous image url, if any // Revoke previous image url, if any
@ -30,17 +28,12 @@
<input type="file" name="image" accept="image/*" on:change={uploadImage} /> <input type="file" name="image" accept="image/*" on:change={uploadImage} />
{#if imageURL} {#if imageURL}
<img src={imageURL} alt="User uploaded" /> <img src={imageURL} alt="User uploaded" />
{#await loadImage(imageURL)} {#await sendImage()}
<p>Loading image data . . .</p> <p>Sending image . . .</p>
<p>{uploadData.elapsed} seconds elapsed.</p> <p>{uploadData.elapsed} seconds elapsed.</p>
{:then data} {:then}
{#await sendImage(data)} <p>Done!</p>
<p>Uploading image data . . .</p> <p>{uploadData.elapsed} seconds elapsed.</p>
<p>{uploadData.elapsed} seconds elapsed.</p> {clearInterval(uploadData.interval)}
{:then}
<p>Done!</p>
<p>{uploadData.elapsed} seconds elapsed.</p>
{clearInterval(uploadData.interval)}
{/await}
{/await} {/await}
{/if} {/if}