public ActionResult uploadPhos(HttpPostedFileBase files) //多图片上传
{ if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\Uploads")) //判断文件夹是否存在 { Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + @"\Uploads"); //不存在则创建文件夹 } string Extension = Path.GetExtension(files.FileName); string newfilename = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss-ms") + Extension; //创建了文件名 string NewFile = AppDomain.CurrentDomain.BaseDirectory + @"\Uploads\" + newfilename; //创建了一条文件路径 files.SaveAs(NewFile); List<img> imgs = new List<img>() { //layui上传文件所需返回的格式 new img() {code=0,msg="",data=newfilename } }; string res = JsonConvert.SerializeObject(imgs); return Json(res); } public class img { public int code { get; set; } public string msg { get; set; } public string data { get; set; } }