public ActionResult SubmitApp(FormCollection fc, HttpPostedFileBase file) { //if (fc.Count != 0) //{ //App_Of_The_DayEntities4 aod = new App_Of_The_DayEntities4(); try { Submit_App sa = new Submit_App(); sa.Actual_Price = Decimal.Parse(fc["actualprice"]); sa.App_Description = fc["description"]; sa.App_Title = fc["title"]; sa.iTunes_Link = fc["link"]; sa.UserID = (long)Session["userid"]; sa.Date = DateTime.Parse(fc["date"]); if (file != null) { string pic = System.IO.Path.GetFileName(file.FileName); string path = System.IO.Path.Combine(Server.MapPath("~/images/profile"), pic); // file is uploaded file.SaveAs(path); // save the image path path to the database or you can send image directly to database // in-case if you want to store byte[] ie. for DB using (MemoryStream ms = new MemoryStream()) { file.InputStream.CopyTo(ms); byte[] array = ms.GetBuffer(); } } //FileInfo fi = new FileInfo(@"E:\Wallpapers\Homeland5"); //fi.CopyTo(@"C:\Users\Sidd\Desktop\App_of_the_day\App_of_the_day\images\profiles\Homeland5.jpg"); sa.App_Icon = "/images/profile/";// +pic; entity.AddToSubmit_App(sa); entity.SaveChanges(); } catch { ViewBag.error = "You have missed some fields please enter all fields"; } //} return View(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)