Click here to Skip to main content
15,890,947 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
In Model
C#
public partial class User
    {
        public int ID { get; set; }
        public string FullName { get; set; }
        public string UserName { get; set; }
        public string Email { get; set; }
        public string Password { get; set; }
        public string SecurityQuestion { get; set; }
        public string SecurityAnswer { get; set; }
        public string Imgurl { get; set; }
        public int PhoneNo { get; set; }
        public int RolesId { get; set; }

        public virtual Role Role { get; set; }
    }

in Controlar

C#
public ActionResult Registration( User user) { if (ModelState.IsValid) { if (Request.Files != null) {

                foreach (string item in Request.Files)
                {
                    HttpPostedFileBase file = Request.Files[item];
                    string url = "/Images/" + file.FileName;
                    file.SaveAs(Request.MapPath(url));
                    user.Imgurl = url;

                }
            }

            db.Users.Add(user);

            db.SaveChanges();
            return RedirectToAction("Admin");
        }

        ViewBag.RolesId = new SelectList(db.Roles, "ID", "Name", user.RolesId);
        return View(user);
    }


What I have tried:

I am create the User Registration form with with image..but not the save path in data base.. how to Resolve My Problem..
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900