public Response<string> SavePost() { var response = new Response<string>(); string rst = ""; try { HttpContextWrapper objwrapper = GetHttpContext(Request); HttpFileCollectionBase collection = objwrapper.Request.Files; string jsonvalue = objwrapper.Request.Form["json"]; if (!string.IsNullOrEmpty(jsonvalue)) { var objitem = JsonConvert.DeserializeObject<ReqSaveEventPost>(jsonvalue); objitem.file = ""; //int count = 0; foreach (string file in collection) { HttpPostedFileBase file1 = collection.Get(file); // HttpPostedFileBase file1 = collection.Get(file); if (file1.ContentType == "video/quicktime" || file1.ContentType == "video/mp4") { var videofile = new byte[file1.ContentLength]; file1.InputStream.Read(videofile, 0, file1.ContentLength); BinaryWriter Writer = null; if (videofile.Length > 0) { string videoname = Guid.NewGuid().ToString().Substring(0, 7) + "_.MOV"; if (file1.ContentType == "video/mp4") { videoname = Guid.NewGuid().ToString().Substring(0, 7) + "_.mp4"; } Writer = new BinaryWriter( File.OpenWrite(HttpContext.Current.Request.PhysicalApplicationPath + "WebImages\\Video\\" + videoname)); Writer.Write(videofile); Writer.Flush(); Writer.Close(); objitem.file = videoname; // count = 1; } } } var objmethod = new UnseenTalentsMethod(); rst = objmethod.SaveEventPost(objitem); response.Create(true, 1, "User login successfully", rst); } else { response.Create(false, 1, "Data not found.", "0"); } } catch (Exception ex) { response.Create(false, -1, Messages.FormatMessage(ex.Message), "0"); } return response; }