feat: show image on upload

This commit is contained in:
Methapon2001 2024-04-17 11:32:18 +07:00
parent 5442477e7d
commit d7e606fb16

View file

@ -108,6 +108,18 @@ const inputFile = document.createElement('input');
inputFile.type = 'file';
inputFile.accept = 'image/*';
const reader = new FileReader();
reader.addEventListener('load', () => {
if (typeof reader.result === 'string') {
urlProfile.value = reader.result;
}
});
watch(profileFile, () => {
if (profileFile.value) reader.readAsDataURL(profileFile.value);
});
inputFile.addEventListener('change', (e) => {
profileFile.value = (e.currentTarget as HTMLInputElement).files?.[0];
});