title: asp.net dynamic multiple file upload
body: <pre><code> protected void btnUpload_Click(object sender, EventArgs e)
      {
          for (int i = 0; i &lt; Request.Files.Count; i++)
          {
              HttpPostedFile PostedFile = Request.Files[i];
              if (PostedFile.ContentLength &gt; 0)
              {
                  string FileName = System.IO.Path.GetFileName(PostedFile.FileName);
                  PostedFile.SaveAs(Server.MapPath("Files\\") + FileName);
              }
          }
      }
  
  &lt;script type="text/javascript"&gt;
          var counter = 0;
          function AddFileUpload() {
              var div = document.createElement('DIV');
              div.innerHTML = '&lt;input id="file' + counter + '" name = "file' + counter +
                              '" type="file" /&gt;' +
                              '&lt;input id="Button' + counter + '" type="button" ' +
                              'value="Remove" onclick = "RemoveFileUpload(this)" /&gt;';
              document.getElementById("FileUploadContainer").appendChild(div);
              counter++;
          }
          function RemoveFileUpload(div) {
              document.getElementById("FileUploadContainer").removeChild(div.parentNode);
          }
      &lt;/script&gt;
  </code></pre>
  
  <p>The upload function can dynamic add as much as user want.</p>
  
  <pre><code> &lt;div&gt;
              &lt;span style="font-family: Arial"&gt;Click to add files&lt;/span&gt;
      &lt;input id="Button1" type="button" value="add" onclick="AddFileUpload()" /&gt;
              &lt;div id="FileUploadContainer"&gt;
              &lt;/div&gt;
              &lt;asp:Button ID="btnUpload" runat="server"
                  Text="Upload" OnClick="btnUpload_Click" /&gt;
  
          &lt;/div&gt;
  </code></pre>
  
  <p>The problem I'm facing now is when I click upload
   <code>for (int i = 0; i &lt; Request.Files.Count; i++)</code> this line , <code>Request.Files.Count always = 0</code>,even when I have 1 or more file to upload.I tried to debug this <code>Request.Files.Count 0</code> always..</p>