Create a label
and place the icon and input file
inside:
<label for="tipofile" class="custom-file-upload">
<input id="tipofile" type="file" name="img_input" value="">
<i class="material-icons icone-img"></i>
</label>
It is necessary that input file
has a id
and in label
put for="id_do_input"
, as shown in the example above.
And in CSS, hide input file
with:
#tipofile{
display: none;
}
Example:
#tipofile{
display: none;
}
/*só para exemplo*/
.icone-img{
width: 100px;
height: 100px;
background-image: url(https://www.cleverfiles.com/howto/wp-content/uploads/2016/08/mini.jpg);
background-size: cover;
}
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<form class="form" method="POST" enctype="multipart/form-data">
<label for="tipofile" class="custom-file-upload">
Clique na imagem:
<br>
<input id="tipofile" type="file" name="img_input" value="">
<i class="material-icons icone-img"></i>
</label>
<input id="Bot_login" type="submit" name="Trocar_img" value="Trocar imagem">
</form>