Reshister.cshtml
<div class="form-group">
@Html.LabelFor(m => m.ProfileImageUpload, new { @class = "col-md-2 control-label" })
<div class="col-md-4">
<input type="file" accept="image/jpeg, image/jpg" onchange="loadFile(event)" name="ProfileImageUpload" id="ProfileImageUpload">
AccountController.cs
string directory = @"~\Upload_Images\";
HttpPostedFileBase ProfileImageUpload = model.ProfileImageUpload; // Request.Files["ProfileImageUpload"];
string fileName = null;
if (ProfileImageUpload != null && ProfileImageUpload.ContentLength > 0)
{
fileName = Path.GetFileName(ProfileImageUpload.FileName);
ProfileImageUpload.SaveAs(Server.MapPath(Path.Combine(directory, fileName)));
}
var user = new ApplicationUser
{
UserName = model.Email,
Email = model.Email,
Fullname = model.Fullname,
Img_Name = fileName,
}