0
As I display an image recorded in the database, I believe that it is not actually recorded, because I can only see the name/format of the image. In this case, how do I display this image?
I looked for some ways to do using custom HTML helpers and so on, but I think I’m forgetting something.
Follow my image upload code:
[HttpPost]
public ActionResult Adicionar(usuario usuario, HttpPostedFileBase foto)
{
if (ModelState.IsValid)
{
db.usuario.Add(usuario);
db.SaveChanges();
var fotoperfil = Path.GetFileName(foto.FileName);
var caminho = Path.Combine(Server.MapPath("~/App_Data/Foto"), fotoperfil);
foto.SaveAs(caminho);
return RedirectToAction("Index");
}
return View(usuario);
}
It is not really being. In what part the Model User receives the file path?
– Leonel Sanches da Silva
Well, I confess that I did not make any changes to the model. In fact, I didn’t see anyone talking about it. I only made the changes to the view and controller itself.
– Ryan Santos