rsd_17 Posted January 22, 2020 at 10:53 PM Report Share #617179 Posted January 22, 2020 at 10:53 PM Ola, Estou a tentar apresentar na view a foto do utilizador mas na base de dados no campo fotografia apenas tenho guardado o nome da fotografia, mas a fotografia esta guardada na pasta Fotos em wwwroot. Ha alguma forma de apresentar a imagem buscando o nome a base de dados e o resto do caminho ? Algo assim ? Mas nao funciona ... <img src="~/Fotos/@Html.DisplayFor(modelItem => item.Fotografia)/> Tenho isto na View : <table class="table"> <thead> <tr> <th> </th> <th> @Html.DisplayNameFor(model => model.Nome) </th> <th> @Html.DisplayNameFor(model => model.Email) </th> <th> @Html.DisplayNameFor(model => model.Telefone) </th> <th> @Html.DisplayNameFor(model => model.Sexo) </th> <th> @Html.DisplayNameFor(model => model.Especialidade) </th> <th> @Html.DisplayNameFor(model => model.Estado) </th> <th> @Html.DisplayNameFor(model => model.Password) </th> <th></th> </tr> </thead> <tbody> @foreach (var item in Model) { <tr> <td> <img src="~/Fotos/" + "@Html.DisplayFor(modelItem => item.Fotografia)" /> </td> <br/> <br/> <td> @Html.DisplayFor(modelItem => item.Nome) </td> <td> @Html.DisplayFor(modelItem => item.Email) </td> <td> @Html.DisplayFor(modelItem => item.Telefone) </td> <td> @Html.DisplayFor(modelItem => item.Sexo) </td> <td> @Html.DisplayFor(modelItem => item.Especialidade) </td> <td> @Html.DisplayFor(modelItem => item.Estado) </td> <td> @Html.DisplayFor(modelItem => item.Password) </td> <td> <a asp-action="Edit" asp-route-id="@item.Idprofessor">Edit</a> | <a asp-action="Details" asp-route-id="@item.Idprofessor">Details</a> | <a asp-action="Delete" asp-route-id="@item.Idprofessor">Delete</a> </td> </tr> } </tbody> </table> Ha alguma forma de colocar a imagem na view desta forma ? Link to comment Share on other sites More sharing options...
M6 Posted January 24, 2020 at 10:45 AM Report Share #617190 Posted January 24, 2020 at 10:45 AM O teu IMG tem de referenciar o caminho ao nível do servidor web, não do file system. Quando metes o caminho da imagem no browser vais ver a imagem, é isso que tens de usar para a tag IMG. 10 REM Generation 48K! 20 INPUT "URL:", A$ 30 IF A$(1 TO 4) = "HTTP" THEN PRINT "400 Bad Request": GOTO 50 40 PRINT "404 Not Found" 50 PRINT "./M6 @ Portugal a Programar." Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now