/// <summary> /// 附件添加 /// </summary> /// <param name="context"></param> /// <returns></returns> public static Attachment AttachmentUpload(HttpPostedFileBase postfile) { IESFile file = Upload(postfile); if (file.FileGuid != null && file.FileGuid != string.Empty) { if (RemoteFileExists(file)) { AttachmentBLL bll = new AttachmentBLL(); Attachment attachment = new Attachment { FileName = file.FileName, ServerID = file.ServerID, FileSize = file.FileSize, Title = file.FileTitle, Guid = file.FileGuid, Source = string.Empty, SourceID = 0, RefFileID = "0" }; if (bll.Attachment_ADD(attachment)) { return(attachment); } } } return(new Attachment()); }
/// <summary> /// 附件添加 /// </summary> /// <param name="context"></param> /// <returns></returns> public static List <Attachment> AttachmentUpload() { HttpFileCollection files = HttpContext.Current.Request.Files; List <Attachment> attachmentlist = new List <Attachment>(); for (int i = 0; i < files.Count; i++) { IESFile file = Upload(files[i]); if (file.FileGuid != null && file.FileGuid != string.Empty) { if (RemoteFileExists(file)) { AttachmentBLL bll = new AttachmentBLL(); Attachment attachment = new Attachment { FileName = file.FileName, ServerID = file.ServerID, FileSize = file.FileSize, Title = file.FileTitle, Guid = file.FileGuid, Source = string.Empty, SourceID = 0, RefFileID = "0" }; if (bll.Attachment_ADD(attachment)) { attachmentlist.Add(attachment); } } } } return(attachmentlist); }