public async Task <ActionResult> Create([Bind(Include = "Id,LostOrFoundItem,NoReward,ItemReward,Description,LocationID,CategoryID,CreationDate,EmailRelayAddress,AdditionalNotes,Visits,Returned,OwnerUserEmail,imageURL,imageTitle,HideItem")] Item item, HttpPostedFileBase files) { if (ModelState.IsValid) { //profanity check bool textContainsProfanity = pf.ValidateTextContainsProfanity(item.Description); if (textContainsProfanity) { item.Description = pf.CleanTextProfanity(item.Description); } string email = (string)(Session["UserEmail"]); item.OwnerUserEmail = email; //allan rodkin image code if (files != null) { string time = DateTime.UtcNow.ToString(); time = time.Replace(" ", "-"); time = time.Replace(":", "-"); time = time.Replace("/", "-"); var filename = Path.GetFileName(time + Path.GetFileName(files.FileName)); var path = Path.Combine(Server.MapPath("~/photos"), filename); string[] paths = path.Split('.'); string filetype = paths[1]; string fullpath = String.Format("{0}.{1}", paths[0], paths[1]); files.SaveAs(fullpath); item.imageURL = "http://localhost:55645/photos/" + filename; // } db.Items.Add(item); await db.SaveChangesAsync(); return(RedirectToAction("Index")); // } ViewBag.CategoryID = new SelectList(db.Categories, "Id", "Category", item.CategoryID); ViewBag.LocationID = new SelectList(db.Locations, "Id", "Location", item.LocationID); return(View(item)); }