public ActionResult UploadSecurityDeposite(DemandDraft model) { using (UOSEntities db = new UOSEntities()) { obj = GetData(); if (!ModelState.IsValid) { return(View(model)); } if (model.ImageFile == null || model.ImageFile.ContentLength <= 0) { ViewBag.DDImageNull = "Please Choose the Image Of Demand Draft"; return(View()); } var allowedExtensions = new[] { ".pdf", ".jpg", ".png", ".jpeg" }; var extension = Path.GetExtension(model.ImageFile.FileName); if (!allowedExtensions.Contains(extension.ToLower())) { ViewBag.DDImageNull = "Image Extension Must Be JPG , JPEG , PNG , PDF"; return(View()); } if (model.ImageFile.ContentLength > (1024 * 300)) { ViewBag.DDImageNull = "Image Size Must BE Less Than 300KB"; return(View()); } string FileName = Path.GetFileNameWithoutExtension(model.ImageFile.FileName); //Converting into Bytes try { Stream fs = model.ImageFile.InputStream; BinaryReader br = new BinaryReader(fs); model.Draft_Scan = br.ReadBytes((Int32)fs.Length); model.FileName = Path.GetFileName(model.ImageFile.FileName); int instid = Convert.ToInt32(obj.Institute_Id); db.BI_Affi_insert_Draft_detail_program_security(instid, obj.Id_year_for_affilation, Convert.ToString(model.bank_name), Convert.ToString(model.bank_address), Convert.ToString(model.branch_code), Convert.ToString(model.amount), Convert.ToDateTime(Convert.ToDateTime(model.deposite_date).ToString("yyyy-MM-dd")), model.Draft_Scan, model.FileName); TempData["Success"] = "Demand Draft Inserted Successfully"; } catch (Exception e) { ViewBag.Exception = "Error In Insertion Please Try Again"; return(View()); } return(RedirectToAction("DemandDraft", "UserAccount")); } }