Upload pdf file
<p>I want to upload Pdf file into my application</p>

<p>So I have ViewModel (I post only relevant code)</p>

<pre><code>public class SubcategoryViewModel
{
    public HttpPostedFileBase PdfFile { get; set; }
    [DisplayName("PDF")]
    public string Pdf { get; set; }
}
</code></pre>

<p>Controller:</p>

<pre><code> public async Task&lt;string&gt; CreateSubcategory(SubcategoryViewModel model)
    {
              string pdf = null;
            if (model.Pdf != null)
            {
                pdf = Guid.NewGuid().ToString().Substring(0, 13) + "_" + model.File.FileName;
                model.Pdf = pdf;
                var path =    Path.Combine(HttpContext.Current.Server.MapPath("~/Content/pdf"), pdf);
                model.File.SaveAs(path);
            }

            var subcategory = new Subcategory
            {
                Pdf = pdf,
            };
            db.SubcategoriesList.Add(subcategory);
            await db.SaveChangesAsync();
</code></pre>

<p>View:</p>

<pre><code>@model Models.ViewModels.SubcategoryViewModel
@using (Html.BeginForm("Create", "Subcategory", FormMethod.Post, new { enctype = "multipart/form-data" })) 
{
&lt;div class="form-group"&gt;
        @Html.LabelFor(model =&gt; model.Pdf, new { @class = "control-label col-md-2" })
        &lt;div class="col-md-10 legend-size"&gt;
            &lt;input type="file" id="file" name="file" /&gt;
        &lt;/div&gt;
    &lt;/div&gt;
</code></pre>

<p>When I action post I don´t received nothing into model.Pdf, so into   <code>if (model.Pdf != null)</code> validation it comes null, and I don´t know why</p>

<p>Anyone have idea why it occurs? Thankyou in advance!</p>