public string SeveImage(string hpf, out string imgaddr)
{
bool isSavedSuccessfully = true;
string fileName = string.Empty;
string fileNames = string.Empty;
try
{
byte[] arr = Convert.FromBase64String(hpf);
MemoryStream ms = new MemoryStream(arr);
Bitmap bmp = new Bitmap(ms);
string dirpath = string.Empty;
dirpath = HttpContext.Current.Server.MapPath("/") + @"/uploadimages/Appeal/";
//var fileName = ImgSavePath + Path.GetRandomFileName() + Path.GetExtension(file.FileName);
if (!Directory.Exists(dirpath))
{
Directory.CreateDirectory(dirpath);
}
//string path = Guid.NewGuid().ToString() + ".Gif";//文件名
string path = Path.GetRandomFileName() + ".png";//文件名
fileName = path;
fileNames = dirpath + fileName; //路径
bmp.Save(fileNames, System.Drawing.Imaging.ImageFormat.Png);
}
catch (Exception ex)
{
log4net.LogManager.GetLogger("AccessTxt").Info("______意见建议保存图片SeveImage方法" + ex.ToString());
isSavedSuccessfully = false;
}
if (isSavedSuccessfully)
{
imgaddr = @"/uploadimages/Appeal/" + fileName; ;
//return GetWebConfig.GetWebKeyValue("upImageIp") + @"/uploadimages/"+ fileName;
return @"/uploadimages/" + fileName;
}
else
{
imgaddr = "";
return "";
}
}