title: MVC Upload File Object reference not set to an instance of an object
body: <p>Thanks for your time. Before I begin I would like to show you my code.</p>
  
  <p>Model</p>
  
  <pre><code>public class Files
  {
      public HttpPostedFileBase Picture { get; set; } 
  }
  </code></pre>
  
  <p>View</p>
  
  <pre><code>@model FileUpload.Models.Picture
  ....
  @using (Html.BeginForm("UploadFileTest", "FileUpload", FormMethod.Post, new { enctype =  "multipart/form-data" }))
  {
      &lt;input type="file" name="Picture" id="Picture" /&gt;
      &lt;input type="submit" name="submit" value="Upload" /&gt;
  }
  </code></pre>
  
  <p>FileUploadController</p>
  
  <pre><code>[HttpPost]
  public ActionResult UploadFileTest(Picture file)
  {
      if (file.File.ContentLength &gt; 0)
      {
          var fileName = Path.GetFileName(file.File.FileName);
          var path = Path.Combine(Server.MapPath("~/Files/"), fileName);
          file.File.SaveAs(path);
      }
      return RedirectToAction("UploadFileTest");
  }
  </code></pre>
  
  <p>After I upload the file and click submit, I received this error message</p>
  
  <blockquote>
    <p>Object reference not set to an instance of an object.</p>
  </blockquote>
  
  <p>at <code>if (file.FileFile.ContentLength &gt; 0)</code></p>