title: Saving image path on db and images into folder asp .net mvc
body: <p>I have issue in uploading images path into database and moving imagesg into folder, here is code: </p>
  
  <pre><code>public ActionResult UploadImages(
              HttpPostedFileBase formFilled,
              HttpPostedFileBase sixPics,
              HttpPostedFileBase buyerCNIC,
              HttpPostedFileBase sellerCNIC
              )
          {
              if (Session["user"] == null)
              {
                  return RedirectToAction("Login", "User");
              }
  
              CustomerDocumentImages dbCustomerDocs = new CustomerDocumentImages();
  
              string recieverName = Request.Form["RecieverName"];
              var allowedExtensions = new[] {
              ".Jpg", ".png", ".jpg", "jpeg"
              };
  
              dbCustomerDocs.FormFilledPhysicalPath = formFilled.ToString();
  
              var _formFilled = Path.GetFileName(formFilled.FileName); //getting only file name(a.jpg)  
  
              var ext = Path.GetExtension(formFilled.FileName);
  
              if (allowedExtensions.Contains(ext))
              {
                  string name = Path.GetFileNameWithoutExtension(_formFilled); //getting file name without extension  
                  string formImage = name + "_" + DateTime.Now + ext; //appending the name with id  
                                                             // store the file inside ~/project folder(Img)  
                  var path = Path.Combine(Server.MapPath("~/Images"), formImage);
                  dbCustomerDocs.FormFilledPhysicalPath = path;
                  dbCustomerDocs.FormFilled = _formFilled;
  
                  dbCustomerDocs.RecieverName = recieverName;
  
                  try
                  {
  
                      var currentAllotmentId = Convert.ToInt32(Request.Form["AllotmentId"]);
                      var dbAllotment = db.Allotments.SingleOrDefault(i =&gt; i.AllotmentId == currentAllotmentId);
                      dbCustomerDocs.AllotmentId = dbAllotment.AllotmentId;
                      dbAllotment.IsCustomerDocsUploaded = true;
  
                  }
                  catch (Exception)
                  {
                      ModelState.AddModelError("", "Please select valid allotment");
                  }
  
  
  
                  db.CustomerDocumentImagess.Add(dbCustomerDocs);
                  db.SaveChanges();
                  formFilled.SaveAs("~Images"+path);
  
                  return RedirectToAction("Index");
  
              }
              else
              {
                  ViewBag.message = "Please choose only Image file";
              }
  
  
              return View();
              }
  </code></pre>
  
  <p>I have also used server.mappath but it woking fine on localhost but giving error on windows live server( on save as method ) , in case of combine.mappath works fine but not moving image into folder. please guide me, thanks in advance.</p>