public ActionResult UploadImages() { try { if (this.Request.Files.Count == 0) { return(this.Json(new ActionResultStatus(10, "请选择文件!"), JsonRequestBehavior.AllowGet)); } var slides = new List <Slide>(); foreach (string requestFile in this.Request.Files) { var file = this.Request.Files[requestFile] as HttpPostedFileBase; if (file.ContentLength == 0) { continue; } var newFileName = Regex.Replace(file.FileName, @".*\.", DateTime.Now.ToString("yyyyMMddHHmmssff") + "."); var savedFileName = Path.Combine( AppDomain.CurrentDomain.BaseDirectory + "\\assets\\upload\\", Path.GetFileName(newFileName)); file.SaveAs(savedFileName); var slide = new Slide() { FileName = file.FileName, FilePath = string.Format("/assets/upload/{0}", newFileName) }; slides.Add(slide); } Slide.CreateList(slides); return(this.Json(new ActionResultStatus(), JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(this.Json(new ActionResultStatus(ex), JsonRequestBehavior.AllowGet)); } }