I've checked this question that treats the same issue but it didn't worked for me . I actually upload an image but when I click on the load button in order to display the image it redirect me to another page but I want to show it in my current page . Do you have an idea of how to resolve this problem ? Here is my controller
[HttpPost]
public ActionResult Index(HttpPostedFileBase file)
{
var fileName = Path.GetFileName(file.FileName);
var path = Path.Combine(Server.MapPath("~/Content"), fileName);
file.SaveAs(path);
return File(path, "image/jpeg");
}
and in my view
@using(Html.BeginForm("Index","Home", FormMethod.Post, new { @enctype = "multipart/form-data" }))
{
<input style="margin-left:40px;cursor:pointer;" type="file" name="file" id="upload1" />
<input type="submit" style="margin-left:40px;cursor:pointer;" id="load1" value="Upload" />
<img src="myimage" alt="Logo" />
}