save image and url

This commit is contained in:
waltem01 2024-02-16 07:16:32 +01:00
parent 0831e751c3
commit a1d177678c

View File

@ -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