HttpPostedFileBase file = Request.Files["imgfile"]; var filePath = "/Upload/image/"; var timeDirectory = DateTime.Now.ToString("yyyyMMdd"); filePath = filePath + timeDirectory; if (!Directory.Exists(Server.MapPath(filePath))) { Directory.CreateDirectory(Server.MapPath(filePath)); } var fileName = Guid.NewGuid().ToString() + ".jpg"; string Path = filePath + "/" + fileName; string allPath = Server.MapPath(Path); //保存图片 file.SaveAs(allPath);