简单的图片上传

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);

 

posted @ 2018-03-20 09:49  之广  阅读(126)  评论(0编辑  收藏  举报
我的博客——易之广