title: Send XLSX file to controller with C# and JavaScript
body: <p>I need to send an <code>XLSX</code> file and also an <code>HTML</code> file to the <code>Controller</code> but I don't know what type the file is for the <code>Model</code> (string, char, byte[]...), how can I pass these files?</p>
  <p>My HTML looks like this:</p>
  <pre><code>                &lt;div class=&quot;flex flex-column&quot;&gt;
                      &lt;!--Para inserir o titulo do email--&gt;
                      &lt;h6&gt;Titulo:&lt;/h6&gt;
                      &lt;input id=&quot;titulo&quot; type=&quot;text&quot; placeholder=&quot;Titulo do Email&quot; style=&quot;margin: 0 !important; width: 280px;&quot; /&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;flex flex-column&quot;&gt;
                      &lt;!--Para inserir o corpo do email--&gt;
                      &lt;h6&gt;Anexar corpo do email:&lt;/h6&gt;
                      &lt;input type=&quot;file&quot; id=&quot;corpo&quot; /&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;flex flex-column&quot;&gt;
                      &lt;!--Para parametro e os emails--&gt;
                      &lt;h6&gt;Importar planilha de e-mails:&lt;/h6&gt;
                      &lt;input type=&quot;file&quot; id=&quot;parametros&quot; /&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;div class=&quot;button-space&quot;&gt;
                  &lt;input class=&quot;btn btn-primary&quot; type=&quot;button&quot; value=&quot;Preparar e-mails&quot; onclick=&quot;CarregarDados()&quot; /&gt;
              &lt;/div&gt;
  </code></pre>
  <p>The JavaScript:</p>
  <pre><code>    function EnviarEmail() {
          const data = {
              Titulo: document.getElementById(&quot;titulo&quot;).value,
              Corpo: document.getElementById(&quot;corpo&quot;).value,
              Parametros: document.getElementById(&quot;parametros&quot;).value
          };
      
          console.log(data);
          //POST request with body equal on data in JSON format
          fetch('/DisparoEmail/EnviaEmail', {
              method: 'POST',
              headers: {
                  'Content-Type': 'application/json',
              },
              body: JSON.stringify(data),
          })
          .then((response) =&gt; response.arrayBuffer())
          //Then with the data from the response in JSON...
          .then((buffer) =&gt; {
      
              const decoder = new TextDecoder('iso-8859-1');
              const text = decoder.decode(buffer);
      
      
              //document.querySelector(&quot;#divListaFila&quot;).innerHTML = text;
          })
          //Then with the error genereted...
          .catch((error) =&gt; {
              console.error('Error:', error);
          });
  
  }
  </code></pre>
  <p>Modell:</p>
  <pre><code>public class DisparoEmailViewModel
  {
      public string Titulo { get; set; }
      public string Corpo { get; set; }
      public string Parametros { get; set; }
      List&lt;Parametro1&gt; Parametro1s { get; set; }
      List&lt;Parametro2&gt; Parametro2s { get; set; }
  
  }
  </code></pre>
  <p>And Controller:</p>
  <pre><code>public bool EnviaEmail(DisparoEmailViewModel email = null)
  {
      if(email != null)
      {
          DisparoEmailExtension teste = new DisparoEmailExtension();
          teste.EnviaEmail(email);
          return true;
      }
      return false;
  }
  </code></pre>