title: File upload issue MVC - assembly reference
body: <p>I'm trying to put together a page whereby a user can upload a file, and it goes to a database. </p>
  
  <p>I'm following a tutorial, and my controller method so far looks like this:</p>
  
  <pre><code>public ActionResult Index()
  {
      ViewData["Message"] = "File Upload";
      foreach (string upload in Request.Files)
      {
          if (!Request.Files[upload].HasFile()) continue;
          string path = AppDomain.CurrentDomain.BaseDirectory + "uploads/";
          string filename = Path.GetFileName(Request.Files[upload].FileName);
          Request.Files[upload].SaveAs(Path.Combine(path, filename));
      }
  
      return View();
  }
  </code></pre>
  
  <p>Here is also an example of what my view looks like:</p>
  
  <pre><code>&lt;p&gt;
      &lt;% using (Html.BeginForm("", "home", FormMethod.Post, new { enctype = "multipart/form-data" }))
         { %&gt;
      &lt;input type="file" name="FileUpload1" /&gt;&lt;br /&gt;
      &lt;input type="submit" name="Submit" id="Submit" value="Upload" /&gt;
      &lt;% } %&gt;
  &lt;/p&gt;
  </code></pre>
  
  <p>I'm currently getting two compile errors however:</p>
  
  <blockquote>
    <ol>
    <li>'System.Web.HttpPostedFileBase' does not contain a definition for
    'HasFile' and no extension method
    'HasFile' accepting a first argument
    of type
    'System.Web.HttpPostedFileBase' could
    be found (are you missing a using
    directive or an assembly reference?)</li>
    <li>The name 'Path' does not exist in the current context</li>
    </ol>
  </blockquote>
  
  <p>Here is also an example of what I'm using for namespaces in the controller:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.Mvc;
  using System.Web.UI.WebControls;
  </code></pre>
  
  <p>I'd be very grateful if anyone could point me in the right direction to fixing this error.</p>