title: Upload in MVC 5 doesn't work with server but work locally in vs
body: <p>I 'm trying to upload a file to a server, my web site is created with MVC 5. When I use visual studio on my computer and all database and foot folder are local files uploaded successfully but when I try to upload to a server files don't upload.</p>
  
  <p>My view is:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;form action="UploadFile" method="post" enctype="multipart/form-data"&gt;
      &lt;label&gt;Upload File:&lt;/label&gt;
      &lt;input type="file" name="file" id="file" /&gt;
      &lt;input type="submit" id="submitbtn" class="btn btn-default" /&gt;
       @ViewBag.Path
  &lt;/form&gt;
  </code></pre>
  
  <p>And controller is:</p>
  
  <pre><code>public ActionResult UploadFile(HttpPostedFileBase file)
  {
      System.Web.HttpContext.Current.Session["path"] = "";
      if (file == null )
          return RedirectToAction("Create");
      if (file.ContentLength &gt; 0)
      {
          var fileName = Path.GetFileName(file.FileName);
          var path = Path.Combine(Server.MapPath("~/attachments/"), fileName);
          file.SaveAs(path);
          pathFile = path;
          ViewBag.Path = path;
      }
      return View("Create");
  }
  </code></pre>
  
  <p>Upload in MVC 5 doesn't work with server but work locally in VS.
  My code is correct because it work locally and my connection to server also is correct because I edit and create record in database inside server by web.</p>