how to add dynamically and upload multiple file with httppostedfilebase in mvc c#

how to add dynamically and upload multiple file with httppostedfilebase in mvc c#

<div class="row" id="fileupload_div">
                        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                            <h6>Upload Your Documents</h6>
                        </div>

                        @foreach (var a in ViewBag.Upload1)
                        {

                            <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
                                <div class="form-group">
                                    <label>@a.ItemArray[1]</label>
                                    <input type="file" class="dropify" name="@a.ItemArray[0]" id="file_@i" required="" data-allowed-file-extensions="pdf png jpg jpeg" />
                                    <input type="hidden" name="@a.ItemArray[0]" id="docname_@i" value="@a.ItemArray[0]" />
                                </div>
                            </div>
                            i++;
                        }

                    </div>
public ActionResult newregistration_form()
        {
                DataTable dt_Upload_Mst = Fetch from database;
                if (dt_Upload_Mst.Rows.Count > 0)
                {
                    ViewBag.Upload1 = dt_Upload_Mst.AsEnumerable().ToList();
                }
                return View();
        }
<script type="text/javascript">
    $("#btn_form_submit").click(function () {
        
var filelength = $('#fileupload_div').find('input[type="file"]').length;
        // var formdata = new FormData();
        for (var i = 1; i <= filelength; i++) {
            var up_file = document.getElementById('file_' + i).files[0];
            var doc_name = document.getElementById('docname_' + i).value;
            fd.append('Uplaod_Files', up_file);
            fd.append('docname', doc_name);
        }
        $.ajax({
            url: '/home/FormSubmit',
            type: "POST",
            dataType: "JSON",
            data: fd,
            contentType: false,
            processData: false,
            success: function (result) {


            }
        })
    });
</script>
public string NewRegistrationFormSubmit(HttpPostedFileBase[] Uplaod_Files, string[] docname)
        {
            string message = "";
            try
            {
                if (Uplaod_Files != null)
                {
                    // Your logic for saving files.
                }
                else
                {
                    message = "Please upload document";
                }
            }
            catch
            {
            }
            return message;
        }

2020-01-15