/// <summary> /// Uploads the user icon. /// </summary> /// <param name="fileInput">The file input.</param> /// <param name="virDir">The vir dir.</param> /// <param name="userid">The userid.</param> /// <param name="scaleLength">Length of the scale.</param> /// <param name="sMode">The s mode.</param> public static void UploadUserIcon(this HtmlInputFile fileInput, string virDir, object userid, int scaleLength, System.Drawing.ScaleModes sMode) { string dir = System.Web.HttpContext.Current.Server.MapPath(virDir); if (!System.IO.Directory.Exists(dir)) { System.IO.Directory.CreateDirectory(dir); } string fileName = userid.ToString() + ".jpg"; string fileSavePath = System.IO.Path.Combine(dir, fileName); System.Drawing.Image img = fileInput.ToImage(); img.Scale(fileSavePath, scaleLength, sMode); }
/// <summary> /// 上传一个用户头像 /// </summary> /// <param name="fileInput">The file input.</param> /// <param name="savingPath">The saving path.</param> /// <param name="scaleLength">Length of the scale.</param> /// <param name="sMode">The s mode.</param> public static void UploadUserIcon(this HtmlInputFile fileInput, string savingPath, int scaleLength, ScaleModes sMode) { System.Drawing.Image img = fileInput.ToImage(); img.Scale(savingPath, scaleLength, sMode); }