Hi
I have below code & i want to upload multiple Excel Files
<div class="col-lg-12"> <asp:FileUpload ID="FileUpload1" runat="server" class="file-input" multiple="multiple" data-show-caption="true" data-show-preview="true" accept=".xlsx,.xls,.csv" /> <asp:RegularExpressionValidator ID="regexValidator" runat="server" ForeColor="Red" ControlToValidate="FileUpload1" ErrorMessage="Only Excel files are allowed" ValidationExpression="^.*\.(xls|xlsx|csv)$"></asp:RegularExpressionValidator> </div>
protected void btnUploadSave_Click(object sender, EventArgs e) { try { if (FileUpload1.HasFile) { string FileName = Path.GetFileName(FileUpload1.PostedFile.FileName); string RandomName = Utility.CurrentDateTime().ToFileTime().ToString(); string Extension = Path.GetExtension(FileUpload1.PostedFile.FileName); string FolderPath = "~/Upload/ExcelUpload/"; string FilePath = Server.MapPath(FolderPath + RandomName + FileName); FileUpload1.SaveAs(FilePath); if (Extension.ToLower() == ".csv") { UploadSave(Utility.ReadCSVFileNew(FilePath)); } else { UploadSave(Utility.ReadExcelFile(FilePath)); } divUpload.Style.Add("display", "none"); btnUploadSave.Style.Add("display", "none"); if (myDataTable0.Rows.Count == 0) { ShowMessageWithRedirect(recno.ToString(), " Leads Uploaded Successfully", "success", "ViewOpenLeads"); } else { ShowMessage(recno.ToString() + " Leads Uploaded Successfully", myDataTable0.Rows.Count + " Duplicate Leads Found", "info"); } } } catch (Exception ex) { Utility.SaveErrorLog(ex.Message, System.IO.Path.GetFileName(Request.Path), System.Reflection.MethodBase.GetCurrentMethod().Name, Convert.ToInt32(hdfBDOID.Value)); ShowMessage("Oops...", ex.Message, "error"); } }
Thanks