接收并转换图片的处理格式链接为:https://www.cnblogs.com/yutang-wangweisong/p/12076990.html
接收并将图片做处理后 在将其命名并进行保存 保存时如果指定的区域内没有此文件夹名称,那么将创建新的文件夹 文件夹的名称不变
//为防止图片流重复 我们使用随机数命名 Random ran = new Random((int)DateTime.Now.Ticks); //图片保存的目录 按照保存日期进行保存 string subPath = "/imgUploads/" + DateTime.Now.ToString("yyyyMMdd") + "/"; // 201901105 //图片保存的目录的绝对路径 string path = context.Server.MapPath(subPath); //判断如果当保存的文件夹不存在时 创建文件夹 if (false == System.IO.Directory.Exists(path)) { //创建pic文件夹 System.IO.Directory.CreateDirectory(path); } string imgName = ran.Next(99999) + ImgExtention; string serverPath = path + imgName;//文件保存位置及命名 string imgPath = subPath + imgName; try { img.Save(serverPath); return imgPath; } catch { return ""; }imgPath = subPath + imgName;