Saturday, May 22, 2010

upload image and save binary format show image in picture box

if (fileuploadlogo.PostedFile.ContentLength == 0)
        {
            lblerrordesc.Visible = true;
            lblerrordesc.Text = "Please Upload Photo !!!";
        }
        else
        {
            Stream imgStream = fileuploadlogo.PostedFile.InputStream;
            int imgLen = fileuploadlogo.PostedFile.ContentLength;
            string imgContentType = fileuploadlogo.PostedFile.ContentType;
            byte[] imgBinaryData = new byte[imgLen];
            int n = imgStream.Read(imgBinaryData, 0, imgLen);
            photodata = imgBinaryData;
            phototype = imgContentType;
            Session["photodata"] = imgBinaryData;
            Session["phototype"] = imgContentType;
            Image3.ImageUrl = "studentphoto.aspx?type=" + imgContentType + "";
        }

No comments:

Post a Comment