Exemple #1
0
        //private void CreateDir(string uid)
        //{
        //    uid = Avatars.FormatUid(uid);
        //    string strPath = string.Format("{0}avatars/upload/{1}/{2}/{3}", new object[]
        //    {
        //        BaseConfigs.GetForumPath,
        //        uid.Substring(0, 3),
        //        uid.Substring(3, 2),
        //        uid.Substring(5, 2)
        //    });
        //    if (!Directory.Exists(Utils.GetMapPath(strPath)))
        //    {
        //        Directory.CreateDirectory(Utils.GetMapPath(strPath));
        //    }
        //}

        private bool SaveAvatar(string avatar, string uid)
        {
            var buf = this.FlashDataDecode(DNTRequest.GetString(avatar));

            if (buf.Length == 0)
            {
                return(false);
            }

            //uid = Avatars.FormatUid(uid);
            string size;

            if (avatar == "avatar1")
            {
                size = "large";
            }
            else if (avatar == "avatar2")
            {
                size = "medium";
            }
            else
            {
                size = "small";
            }

            //string strPath = string.Format("{0}avatars/upload/{1}/{2}/{3}/{4}_avatar_{5}.jpg", new object[]
            //{
            //    BaseConfigs.GetForumPath,
            //    uid.Substring(0, 3),
            //    uid.Substring(3, 2),
            //    uid.Substring(5, 2),
            //    uid.Substring(7, 2),
            //    size
            //});
            var strPath = Avatars.FormatPathPrefix(uid) + size + ".jpg";

            File.WriteAllBytes(strPath.EnsureDirectory(), buf);
            //FileStream fileStream = new FileStream(Utils.GetMapPath(strPath), FileMode.Create);
            //fileStream.Write(buf, 0, buf.Length);
            //fileStream.Close();
            return(true);
        }