if (HttpContext.Current.Request.Files.Count > 0)
{
string pathbase = "/upload/order/" + DateTime.Now.ToString("yyyy/");
string uploadpath = HttpContext.Current.Server.MapPath("~" + pathbase);//获取文件上传路径
if (!Directory.Exists(uploadpath))
{
Directory.CreateDirectory(uploadpath);
}
for (var i = 0; i < HttpContext.Current.Request.Files.Count; i++)
{
var uploadFile = HttpContext.Current.Request.Files[i];
string newName = Guid.NewGuid().ToString() + Path.GetExtension(uploadFile.FileName);
//保存图片的逻辑
uploadFile.SaveAs(uploadpath + newName);
TAttachmentInfo attchInfo = new TAttachmentInfo()
{
FileOriginalName = uploadFile.FileName,
FileNewName = newName,
FilePath = pathbase + newName,
FileSize = uploadFile.ContentLength,
Creator = 0,
Status = StatusEnum.Active,
FileType = AttachmentFileTypeEnum.Image,
InsertTime = DateTime.Now,
RefID = 5,
RefType = RefTypeEnum.OrderEvaluationImg
};
itattachment.CreateTAttachment(attchInfo);
break;
}
}