asp.net MVC upload file get null in action's parameter
<p>I was trying to upload a file. I followed these examples:</p>

<p><a href="http://haacked.com/archive/2010/07/16/uploading-files-with-aspnetmvc.aspx/" rel="nofollow">http://haacked.com/archive/2010/07/16/uploading-files-with-aspnetmvc.aspx/</a>
<a href="http://www.mikesdotnetting.com/article/259/asp-net-mvc-5-with-ef-6-working-with-files" rel="nofollow">http://www.mikesdotnetting.com/article/259/asp-net-mvc-5-with-ef-6-working-with-files</a></p>

<p>When I check the file in my Edit Action, it was null. Where did I do wrong? Here are my codes:</p>

<p>Controller:</p>

<pre><code>[HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Edit(int? id, FormCollection form, string addFileButton, HttpPostedFileBase file)
        {
            var cardKey = db.CardKeys.Include(c =&gt; c.Request).Single(c =&gt; c.CardKeyID == id);

            if (addFileButton != null)
            {
                if (file != null &amp;&amp; file.ContentLength &gt; 0)
                {
                    var fileName = Path.GetFileName(file.FileName);
                    var path = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName);
                    file.SaveAs(path);
                }
                return View(cardKey);
            }

            UpdateRequestClearances(form["Clearances"].Split(','), cardKey.Request);

            if (ModelState.IsValid)
            {
                db.Entry(cardKey).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            ViewBag.DepartmentID = new SelectList(db.Departments, "DepartmentID", "DepartmentName", cardKey.DepartmentID);
            ViewBag.DivisionID = new SelectList(db.Divisions, "DivisionID", "DivisionName", cardKey.DivisionID);
            ViewBag.ProgramID = new SelectList(db.Programs, "ProgramID", "ProgramName", cardKey.ProgramID);
            return View(cardKey);
        }
</code></pre>

<p>View: (I omit many irrelevant codes)</p>

<pre><code>@using (Html.BeginForm("Edit","CardKeys",FormMethod.Post,new { enctype="multipart/form-data"}))
{
    @Html.AntiForgeryToken()

    &lt;div class="form-horizontal"&gt;
        &lt;h4&gt;CardKey&lt;/h4&gt;
        &lt;hr /&gt;
&lt;div class="form-group"&gt;
            @Html.Label("File Upload", new { @class="control-label col-md-4"})
            &lt;div class="col-md-8"&gt;
                &lt;input type="file" multiple="multiple" id="files" /&gt;
                &lt;input type="submit" name="addFileButton" id="btnAddFile" value="add files" /&gt;
            &lt;/div&gt;
        &lt;/div&gt;        
        &lt;div class="form-group"&gt;
            &lt;div class="col-md-offset-2 col-md-10"&gt;
                &lt;input type="submit" value="Save" class="btn btn-default" /&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
</code></pre>

<p>I open visual studio as an administrator to make sure this is not a permission issue.</p>