I wanted something that, when the user clicks on the image, they can choose a file to upload.
This is my HTML:
<div class="align-center">
<img [src]="selectedFile" *ngIf="selectedFile" class="img-profile">
<img src="../../assets/img/placeholder.png" *ngIf="!selectedFile" class="img-profile">
</div>
Conceptually, what I want to do is basically akin to having the <input>
tag and then the <img>
tag inside it, although I know that wouldn't work practically.
I tried many different things, such as putting the <img>
tag inside the <input>
tag; I tried having the input somewhere else and then assigning its id to the img (click) function but still nothing worked.
Can anyone suggest a way to do this, since I've been stuck on this for way too long?