I cannot add image in about -> post method. This is my code please help.
This is my controller section:
ActionResult Register(Admin adm)
{
string fileName = Path.GetFileNameWithoutExtension(adm.ImageFile.FileName);
string exe = Path.GetExtension(adm.ImageFile.FileName);
fileName = fileName + DateTime.Now.ToString("yymmssfff") + exe;[enter image description here][1]
adm.Adm_Image_path = "~/Image/" + fileName;
fileName = Path.Combine(Server.MapPath("~/Image/"), fileName);
adm.ImageFile.SaveAs(fileName);
// Upload_Image(adm.ImageFile);
if (ModelState.IsValid)
{
if (adm.Adm_Password == adm.Adm_Confirm_Password)
{
adm.Adm_Type = "Admin";
db.admin.Add(adm);
db.SaveChanges();
return RedirectToAction("Login", "Home");
}
}
return View();
}
View section here
<div class="form-group">
@Html.LabelFor(x => x.Adm_Image_path, new { @class = "control-label col-md-2" })
<div class="col-md-10">
<input type="file" name="ImageFile" id="ImageFile" value="ImageFile" required />
@Html.ValidationMessageFor(x => x.Adm_Image_path, "", new { @class="text-danger"})
</div>
</div>
<input type="submit" value="Save" class="btn btn-default" />`
I cannot upload the image in the specific section.