-1
I have an application, where the user can store the profile photo.
Save the image in C:/imgPerfil/
concatenating the user id with the original image name.
Example: "2test.jpeg".
I need to show this image on the front using thymeleaf
, How do you do that?
The Path is saved inside the user object in the photo variable, also picked up the data by Ajax.
HTML:
<img id="fotoUsuario" class="circle" th:src="@{usuario.foto}" style="margin-left: 35%"></img>
JS:
<script type="text/javascript" charset="UTF-8">
var nome;
var foto;
$.ajax({
url: '/getPerfil',
type: 'GET',
success: function (perfil) {
nome = perfil[0].nome;
foto = perfil[0].foto;
console.log(perfil[0]);
$("#nomeUsuario").text(nome);
$("fotoUsuario").attr('src', foto);
}
});
</script>
How to display this image?