title: Determine if uploaded file is image (any format) on MVC
body: <p>So I'm using this code for view:</p>
  
  <pre><code>&lt;form action="" method="post" enctype="multipart/form-data"&gt;
  
    &lt;label for="file"&gt;Filename:&lt;/label&gt;
    &lt;input type="file" name="file" id="file" /&gt;
  
    &lt;input type="submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>This for model:</p>
  
  <pre><code>[HttpPost]
  public ActionResult Index(HttpPostedFileBase file) {
  
    if (file.ContentLength &gt; 0) {
      var fileName = Path.GetFileName(file.FileName);
      var path = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName);
      file.SaveAs(path);
    }
  
    return RedirectToAction("Index");
  }
  </code></pre>
  
  <p>Works great unless the user add a file which isn't an image. How can I assure the file uploaded is an image. Thanks</p>