title: How to Drop Multiple files in Dropzone.js in ASP.Net core Razorpages
body: <p>Im Stuck with the problem that I can't get the &quot;UploadMultiple&quot; to work.
  Whenever I try to Drop more than one File at once (drag and dropp 3 selected PDF files for example) I don't recieve any files in the c# controller.</p>
  <p>The View seems to work, as there are no errors when dropping the Files.
  In the controller however, I don't recieve any files (files.Count = 0).</p>
  <p>these are my code snippets:</p>
  <p><strong>View HTML:</strong></p>
  <pre><code>&lt;div class=&quot;col-md-8&quot;&gt;
      &lt;form id=&quot;fileUploadForm&quot; class=&quot;text-center dropzone needsclick dz-clickable&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot; style=&quot;min-height: 500px;&quot;&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>
  <p><strong>JS:</strong></p>
  <pre><code>Dropzone.autoDiscover = false;
  $(&quot;#fileUploadForm&quot;).dropzone({
      url: &quot;/UploadView&quot;,
      paramName: &quot;files&quot;,
      uploadMultiple: true,
      parallelUploads: 1,
      maxFilesize: 50,
      init: function () {
          this.on('success', function (file) {
  
              var element = document.getElementById(&quot;submitbutton&quot;);
              element.style.display = &quot;inline&quot;;
  
              var args = Array.prototype.slice.call(arguments);
              var lowercaseName = file.name.toLowerCase()
              if (!lowercaseName.includes(&quot;.pdf&quot;) &amp;&amp; args[1] === &quot;success&quot;) {
                  $(&quot;#directUploadDocs&quot;).append(&quot;&lt;p&gt;&quot; + file.name + &quot;&lt;/p&gt;&lt;br /&gt;&quot;);
              } else {
                  switch (args[1]) {
                      case &quot;HashFailed&quot;:
                          $(&quot;#errorDocs&quot;).append(&quot;&lt;div&gt;&lt;h4&gt;CUSTOM_TEXT&lt;/h4&gt;&lt;p&gt;&quot; + file.name + &quot;&lt;/p&gt;&lt;/div&gt;&quot;);
                          break;
                      case &quot;UnknownFile&quot;:
                          $(&quot;#errorDocs&quot;).append(&quot;&lt;div&gt;&lt;h4&gt;CUSTOM_TEXT&lt;/h4&gt;&lt;p&gt;&quot; + file.name + &quot;&lt;/p&gt;&lt;/div&gt;&quot;);
                          break;
                      case &quot;success&quot;:
                          console.log(&quot;success&quot;);
                          break;
                      default:
                          console.log(&quot;sorry an error happened&quot;);
                  }
              }
          });
      },
  });
  </code></pre>
  <p><strong>C# Controller:</strong></p>
  <pre><code>public async Task&lt;IActionResult&gt; OnPostAsync(ICollection&lt;IFormFile&gt; files)
  {
      var directoryPath = Path.Combine(_appSettings.UploadFolder, user.SessionID);
      Directory.CreateDirectory(directoryPath);
  
      foreach (var file in files)
      {
          var uploadPath = Path.Combine(_appSettings.UploadFolder, user.SessionID, Guid.NewGuid().ToString() + Path.GetExtension(file.FileName));
          if (file.Length &gt; 0)
          {
              Do Something;
          }
      }
  
      return Content(&quot;success&quot;);
  }
  </code></pre>
  <p>I know that I wrote pretty custom code additional to the reccomended code from dropzone.js, but I hope its still possible to fix that Problem.</p>
  <hr />
  <p><strong>SOLVED!
  SOLUTION:</strong></p>
  <p>Bruce Adams Posted an answer that actually worked for me:</p>
  <p><strong>new C# controller:</strong></p>
  <pre><code>public async Task&lt;IActionResult&gt; OnPostAsync()
  {
      var directoryPath = Path.Combine(_appSettings.UploadFolder, user.SessionID);
      Directory.CreateDirectory(directoryPath);
  
      foreach (var file in Request.Form.Files)
      {
          var uploadPath = Path.Combine(_appSettings.UploadFolder, user.SessionID, Guid.NewGuid().ToString() + Path.GetExtension(file.FileName));
          if (file.Length &gt; 0)
          {
              Do Something;
          }
      }
  
      return Content(&quot;success&quot;);
  }
  
  </code></pre>