byte[] bt = Convert.FromBase64String(image);//获取图片base64
string fileName = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString();//年月
string ImageFilePath = "/Attachment" + "/" + fileName;
if (System.IO.Directory.Exists(HttpContext.Current.Server.MapPath(ImageFilePath)) == false)//如果不存在就创建文件夹
{
System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath(ImageFilePath));
}
string ImagePath = HttpContext.Current.Server.MapPath(ImageFilePath) + "/" +System.DateTime.Now.ToString("yyyyHHddHHmmss");//定义图片名称
File.WriteAllBytes(ImagePath + ".png", bt); //保存图片到服务器,然后获取路径
result = ImagePath + ".png";//获取保存后的路径