handle loading image from url

This commit is contained in:
waltem01 2024-02-15 08:18:22 +01:00
parent 664c58e863
commit 60fd19cb17

View File

@ -13,7 +13,18 @@
async function loadImage(url: string): Promise<ImageData> {}
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);
}
</script>
<input type="file" name="image" accept="image/*" on:change={uploadImage} />