protected void btnSaveImageData_Click(object sender, EventArgs e) { string str = this.RePlaceImg.Value; int photoId = Convert.ToInt32(this.RePlaceId.Value); string photoPath = GalleryHelper.GetPhotoPath(photoId); string str3 = photoPath.Substring(photoPath.LastIndexOf(".")); string extension = string.Empty; string str5 = string.Empty; try { HttpPostedFile postedFile = base.Request.Files[0]; extension = Path.GetExtension(postedFile.FileName); if (str3 != extension) { this.ShowMsgToTarget("上传图片类型与原文件类型不一致!", false, "parent"); } else { string str6 = Globals.GetStoragePath() + "/gallery"; str5 = photoPath.Substring(photoPath.LastIndexOf("/") + 1); string str7 = str.Substring(str.LastIndexOf("/") - 6, 6); string virtualPath = string.Empty; if (str7.ToLower().Contains("weibo")) { virtualPath = Globals.GetStoragePath() + "/weibo/"; } else { virtualPath = str6 + "/" + str7 + "/"; } int contentLength = postedFile.ContentLength; string path = base.Request.MapPath(virtualPath); string text1 = str7 + "/" + str5; DirectoryInfo info = new DirectoryInfo(path); if (!info.Exists) { info.Create(); } if (!ResourcesHelper.CheckPostedFile(postedFile, "image")) { this.ShowMsgToTarget("文件上传的类型不正确!", false, "parent"); } else if (contentLength >= 0x1f4000) { this.ShowMsgToTarget("图片文件已超过网站限制大小!", false, "parent"); } else { postedFile.SaveAs(base.Request.MapPath(virtualPath + str5)); GalleryHelper.ReplacePhoto(photoId, contentLength); this.CloseWindow(); } } } catch { this.ShowMsgToTarget("替换文件错误!", false, "parent"); } }
protected void btnSaveImageData_Click(object sender, System.EventArgs e) { string value = this.RePlaceImg.Value; int photoId = System.Convert.ToInt32(this.RePlaceId.Value); string photoPath = GalleryHelper.GetPhotoPath(photoId); string a = photoPath.Substring(photoPath.LastIndexOf(".")); string b = string.Empty; string text = string.Empty; try { System.Web.HttpFileCollection files = base.Request.Files; System.Web.HttpPostedFile httpPostedFile = files[0]; b = System.IO.Path.GetExtension(httpPostedFile.FileName); if (a != b) { this.ShowMsg("上传图片类型与原文件类型不一致!", false); } else { string str = Globals.ApplicationPath + HiContext.Current.GetStoragePath() + "/gallery"; text = photoPath.Substring(photoPath.LastIndexOf("/") + 1); string text2 = value.Substring(value.LastIndexOf("/") - 6, 6); string text3 = str + "/" + text2 + "/"; int contentLength = httpPostedFile.ContentLength; string path = base.Request.MapPath(text3); //修改1 System.IO.DirectoryInfo directoryInfo = new System.IO.DirectoryInfo(path); if (!directoryInfo.Exists) { directoryInfo.Create(); } if (!ResourcesHelper.CheckPostedFile(httpPostedFile)) { this.ShowMsg("文件上传的类型不正确!", false); } else { if (contentLength >= 2048000) { this.ShowMsg("图片文件已超过网站限制大小!", false); } else { httpPostedFile.SaveAs(base.Request.MapPath(text3 + text)); GalleryHelper.ReplacePhoto(photoId, contentLength); this.CloseWindow(); } } } } catch { this.ShowMsg("替换文件错误!", false); } }
protected void btnSaveImageData_Click(object sender, System.EventArgs e) { string str = this.RePlaceImg.Value; int photoId = System.Convert.ToInt32(this.RePlaceId.Value); string photoPath = GalleryHelper.GetPhotoPath(photoId); string str2 = photoPath.Substring(photoPath.LastIndexOf(".")); string extension = string.Empty; string str3 = string.Empty; try { System.Web.HttpPostedFile postedFile = base.Request.Files[0]; extension = System.IO.Path.GetExtension(postedFile.FileName); if (str2 != extension) { this.ShowMsg("上传图片类型与原文件类型不一致!", false); } else { string str4 = Globals.GetStoragePath() + "/gallery"; str3 = photoPath.Substring(photoPath.LastIndexOf("/") + 1); string str5 = str.Substring(str.LastIndexOf("/") - 6, 6); string virtualPath = str4 + "/" + str5 + "/"; int contentLength = postedFile.ContentLength; string path = base.Request.MapPath(virtualPath); string text = str5 + "/" + str3; System.IO.DirectoryInfo info = new System.IO.DirectoryInfo(path); if (!info.Exists) { info.Create(); } if (!ResourcesHelper.CheckPostedFile(postedFile)) { this.ShowMsg("文件上传的类型不正确!", false); } else { if (contentLength >= 2048000) { this.ShowMsg("图片文件已超过网站限制大小!", false); } else { postedFile.SaveAs(base.Request.MapPath(virtualPath + str3)); GalleryHelper.ReplacePhoto(photoId, contentLength); this.CloseWindow(); } } } } catch { this.ShowMsg("替换文件错误!", false); } }
protected void btnSaveImageData_Click(object sender, EventArgs e) { string value = this.RePlaceImg.Value; int photoId = Convert.ToInt32(this.RePlaceId.Value); string photoPath = GalleryHelper.GetPhotoPath(photoId); string a = photoPath.Substring(photoPath.LastIndexOf(".")); string empty = string.Empty; string empty2 = string.Empty; try { HttpFileCollection files = base.Request.Files; HttpPostedFile httpPostedFile = files[0]; empty = Path.GetExtension(httpPostedFile.FileName); if (a != empty) { this.ShowMsg("上传图片类型与原文件类型不一致!", false); } else { string str = HiContext.Current.GetStoragePath() + "/gallery"; empty2 = photoPath.Substring(photoPath.LastIndexOf("/") + 1); string text = value.Substring(value.LastIndexOf("/") - 6, 6); string text2 = str + "/" + text + "/"; int contentLength = httpPostedFile.ContentLength; string path = base.Request.MapPath(text2); string text3 = text + "/" + empty2; DirectoryInfo directoryInfo = new DirectoryInfo(path); if (!directoryInfo.Exists) { directoryInfo.Create(); } if (!ResourcesHelper.CheckPostedFile(httpPostedFile, "image", null)) { this.ShowMsg("文件上传的类型不正确!", false); } else if (contentLength >= 2048000) { this.ShowMsg("图片文件已超过网站限制大小!", false); } else { httpPostedFile.SaveAs(base.Request.MapPath(text2 + empty2)); GalleryHelper.ReplacePhoto(photoId, contentLength); this.CloseWindow(); } } } catch { this.ShowMsg("替换文件错误!", false); } }
private void btnSaveImageData_Click(object sender, EventArgs e) { string str = RePlaceImg.Value; int photoId = Convert.ToInt32(RePlaceId.Value); string photoPath = GalleryHelper.GetPhotoPath(photoId); string str3 = photoPath.Substring(photoPath.LastIndexOf(".")); string extension = string.Empty; string str5 = string.Empty; try { HttpPostedFile postedFile = base.Request.Files[0]; extension = Path.GetExtension(postedFile.FileName); if (str3 != extension) { ShowMsg("上传图片类型与原文件类型不一致!", false); return; } string str6 = Globals.ApplicationPath + HiContext.Current.GetStoragePath() + "/gallery"; str5 = photoPath.Substring(photoPath.LastIndexOf("/") + 1); string str7 = str.Substring(str.LastIndexOf("/") - 6, 6); string virtualPath = str6 + "/" + str7 + "/"; int contentLength = postedFile.ContentLength; string path = base.Request.MapPath(virtualPath); string str10 = str7 + "/" + str5; DirectoryInfo info = new DirectoryInfo(path); if (!info.Exists) { info.Create(); } if (!ResourcesHelper.CheckPostedFile(postedFile)) { ShowMsg("文件上传的类型不正确!", false); return; } if (contentLength >= 0x1f4000) { ShowMsg("图片文件已超过网站限制大小!", false); return; } postedFile.SaveAs(base.Request.MapPath(virtualPath + str5)); GalleryHelper.ReplacePhoto(photoId, contentLength); } catch { ShowMsg("替换文件错误!", false); return; } BindImageData(); }