How to put an input file which can be clicked on an image?

0

Please I would like you to help me within a div place an input file to which I can select an image.

<div class="" (click)="()" >
                <input id="" type="file" (change)="()">
                <img class="" src={{img}} (click)="">
                <p class="">Texto de ejemplo</p>
              </div>
    
asked by Enric 28.03.2018 в 17:03
source

1 answer

0

You could simply add a label :

Option 1:

If the label contains both the input and the img , then making click on img will be as if you had done click on input .

Demo:

<div class="" (click)="()">
  <label>
    <input id="" type="file" (change)="()">
    <img class="" src={{img}} (click)="">
  <label>
  <p class="">Texto de ejemplo</p>
</div>

Option 2:

If the label contains only the img and also add the attribute for whose value is equal to id of input , then doing click on img will be as if there were done click on input .

Demo:

<div class="" (click)="()">
  <input id="archivo" type="file" (change)="()">
  <label for="archivo">
    <img class="" src={{img}} (click)="">
  <label>
  <p class="">Texto de ejemplo</p>
</div>
    
answered by 28.03.2018 в 17:14