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);
原文地址:https://www.cnblogs.com/shiyige-216/p/8607477.html
时间: 2024-12-20 15:44:12