TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
vijayaasri palaniappan
NA
117
10.1k
Update Image - It return Image file null.
Apr 22 2021 6:33 AM
Here is my code. ' If ' condition is false it go to the else part.
[HttpPost]
public ActionResult DetailsEdit(EmployeeData___TBL e, HttpPostedFileBase ImageFile)
{
if (e.ImageFile != null)
{
string filename = Path.GetFileNameWithoutExtension(e.ImageFile.FileName);
string extension = Path.GetExtension(e.ImageFile.FileName);
HttpPostedFileBase postedfile = e.ImageFile;
int length = postedfile.ContentLength;
if (extension.ToLower() == ".jpg" || extension.ToLower() == ".jpeg" || extension.ToLower() == ".png")
{
if (length <= 1000000)
{
filename = filename + extension;
e.ProfileImage = "~/images/" + filename;
filename = Path.Combine(Server.MapPath("~/images/"), filename);
e.ImageFile.SaveAs(filename);
db.Entry(e).State = EntityState.Modified;
// int a = db.SaveChanges();
db.SP_UpdateUserInfo(e.UserId,e.Name, e.EmailID, e.PhoneNo, e.Address, e.ProfileImage);
//TempData["UpdateMessage"] = "<script>alert('Data Updated Successfully.')</script>";
ModelState.Clear();
return View();
}
Reply
Answers (
6
)
Dropdwonlist ith check box in mvc
How to store multiple dropdown check box values in database in MVC C#