Exemplo n.º 1
0
        //保存头像
        private void buttonSaveFace_Click(object sender, EventArgs e)
        {
            string    responseText;
            UploadPic httpRequestClient = new UploadPic();

            httpRequestClient.SetFieldValue("username", AppInfo.PERSONAL_INFO.Username);//加数据
            byte[] imageBytes;
            using (MemoryStream ms = new MemoryStream())
            {
                currentImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                ms.Position = 0;
                imageBytes  = new byte[ms.Length];
                ms.Read(imageBytes, 0, imageBytes.Length);
            }
            httpRequestClient.SetFieldValue("face", "***", "application/octet-stream", imageBytes);
            httpRequestClient.Upload(AppConst.WebUrl + "baseInfo", out responseText);
            Debug.Print("上传结果是" + responseText);
            if (responseText == "true")
            {
                //修改新头像
                AppInfo.SELF_FACE = this.currentImage;
                saveOKSafePost();
                //修改本地缓存的头像
                //本地缓存
                this.currentImage.Save(AppConst.WinPicPath + "friend" + AppInfo.PERSONAL_INFO.Username + ".jpg");
            }
            else
            {
                MessageBox.Show("更改失败!");
            }
        }
Exemplo n.º 2
0
        //保存头像
        private void buttonSaveFace_Click(object sender, EventArgs e)
        {
            string    responseText;
            UploadPic httpRequestClient = new UploadPic();

            httpRequestClient.SetFieldValue("gid", m_gid.ToString());//加数据
            byte[] imageBytes;
            using (MemoryStream ms = new MemoryStream())
            {
                currentImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                ms.Position = 0;
                imageBytes  = new byte[ms.Length];
                ms.Read(imageBytes, 0, imageBytes.Length);
            }
            httpRequestClient.SetFieldValue("face", "***", "application/octet-stream", imageBytes);
            httpRequestClient.Upload(AppConst.WebUrl + "groupBaseInfo", out responseText);
            Debug.Print("上传结果是" + responseText);
            if (responseText == "true")
            {
                //修改新头像
                m_FormShowGroupInfo.refreshFaceSafePost(currentImage);

                ////修改本地缓存的头像
                //this.currentImage.Save(AppConst.WinPicPath + "group"+ m_gid + ".jpg");
                //FaceMgr.Instance.modifyFace(m_gid);
                saveOKSafePost();
            }
            else
            {
                MessageBox.Show("更改失败!");
            }
        }