title: AspnetCore.Mvc Upload file error, the var caminho always null even with IFormfile valid
body: <p>I try upload a image, but var root is always null...</p>
  
  <p>NullReferenceException: Object reference not set to an instance of an object.</p>
  
  <pre><code>[HttpPost]
  [ValidateAntiForgeryToken]
  public async Task&lt;IActionResult&gt; Create([Bind("Vinhoid,Nome,Ano,Teoralcool,Produtorid,Tipoid,Regiaoid,Datacriacao,Localimagem,Garrafid,Descricao,Preco,Stock")] VinhoDistribuicao vinhoDistribuicao, IFormFile Localimagem)
  {
      if (HttpContext.Session.GetString("TipoUtilizador") == "Garrafeira")
  
  
  
  
      {
          if (ModelState.IsValid)
          {
             if (_context.Vinho.Any(x =&gt; x.Ano == vinhoDistribuicao.Ano &amp;&amp; x.Nome == vinhoDistribuicao.Nome &amp;&amp; x.Tipoid == vinhoDistribuicao.Tipoid) == false)
  
             {
  
                  var caminho = Path.Combine(he.WebRootPath + "/ImageFiles",
                      Path.GetFileName(Localimagem.FileName));
  
                  FileStream fileStream = new FileStream(caminho, FileMode.Create);
                  Localimagem.CopyTo(fileStream);
                  fileStream.Close();
  </code></pre>
  
  <p>HTML</p>
  
  <pre><code>@model Lab4_Vinhos6.Models.VinhoDistribuicao
  
  &lt;div class="form-group"&gt;
      &lt;label asp-for="Localimagem" class="control-label"&gt;&lt;/label&gt;
      &lt;input asp-for="Localimagem" type="file" accept=".png, .jpg" class="form-control" value="" /&gt;
  
      &lt;span asp-validation-for="Localimagem" class="text-danger"&gt;&lt;/span&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>NullReferenceException: Object reference not set to an instance of an object.</p>
  
  <pre><code>var caminho = Path.Combine(he.WebRootPath + "/ImageFiles",
  </code></pre>