title: Path is not a valid virtual path while uploading image to server in asp.net mvc
body: <p>I want to upload image to the server, but image can be uploaded locally to a project folder with <code>~/images/profile</code>, but if I use full path, it does not upload to the server. The code which I am using is given below with a sample url. Please help to solve my problem. I have seen other links of stackoverflow, but they are not working. It gives error message of path is not a valid. Virtual path and the <code>SaveAs</code> method is configured to require a rooted path, and the path is not rooted.</p>
  
  <pre><code>public ActionResult FileUpload(HttpPostedFileBase file, tbl_Image model)
  {
      if (file != null)
      {
          string pic = System.IO.Path.GetFileName(file.FileName);
          string path = System.IO.Path.Combine(Server.MapPath("http://sampleApp.com/images/profile/"), pic);
          file.SaveAs(path);
          db.AddTotbl_Image(new tbl_Image() { imagepath = "http://sampleApp.com/images/profile/" + pic });
          db.SaveChanges();
      }
  
      return View("FileUploaded", db.tbl_Image.ToList());
  }
  </code></pre>