private void ProcessActivityCover(HttpContext context) { try { HttpPostedFile fileUpload = context.Request.Files["Filedata"]; int uid = CU.ToInt(context.Request.QueryString["uid"]); int aid = CU.ToInt(context.Request.QueryString["aid"]); string name = context.Request.QueryString["n"]; if (uid > 0 && !string.IsNullOrEmpty(name)) { if (fileUpload.ContentLength > 0) { string fileName = fileUpload.FileName; string originalPath = @"s\o\180x120\"; string coverPath = @"s\c\180x120\"; string ofileName = rootPath + originalPath + "\\" + fileName; if (SaveFile(fileUpload, ofileName)) { string cfileName = rootPath + coverPath + "\\" + name; IU.Resize(ofileName, cfileName, 180, 120); File.Delete(ofileName); string url = "/s/c/180x120/" + name; if (aid > 0 && FileDB.ExistUploadInfo(uid, aid, 2)) { //不创建上传信息 } else { FileDB.CreateAttachment(new AttachmentEntity() { uid = uid, referid = aid, url = "/s/c/180x120/" + name, physicalpath = cfileName, type = 2 }); } context.Response.StatusCode = 200; context.Response.Write("/s/c/180x120/" + name); return; } } } } catch { } //内部服务器错误 context.Response.StatusCode = 500; context.Response.Write("内部服务器错误"); }
public static int CreateAttachment(AttachmentEntity info) { return(FileDB.CreateAttachment(info)); }