public static void AddTrAttachments(int ticketId, string ticketNo, List <string> attachments, int currentAttachmentCount) { TicketAttachmentBusinessService ticketAttachmentBs = Factory.Create <TicketAttachmentBusinessService>("TicketAttachment", ClassType.clsTypeBusinessService); TicketAttachment ticketAttachment = Factory.Create <TicketAttachment>("TicketAttachment", ClassType.clsTypeDataModel); string path = HttpContext.Current.Server.MapPath("~/Upload/TechnicalRequestAttachments/"); for (int i = 0; i < attachments.Count; i++) { string filePath = path + ticketNo + "-" + i + @".jpg"; var img2 = attachments[i].Replace("data:image/jpeg;base64,", ""); File.WriteAllBytes(filePath, Convert.FromBase64String(img2)); ticketAttachment.TicketId = ticketId; ticketAttachment.Name = ticketNo + "-" + i + @".jpg"; ticketAttachment.LevelUser = ""; ticketAttachment.Status = 1; ticketAttachmentBs.Add(ticketAttachment); } }