Friday, June 6, 2025

how to convert byte array to image in asp.net

Byte[] bytes =  fileUpload1.FileBytes;

  MemoryStream m = new MemoryStream(bytes);

     System.Drawing.Image MyImage = System.Drawing.Image.FromStream(m);            

            string filepathandname = Server.MapPath(string.Format("~/uploads/{0}-{1}-{2}", DateTime.Now.ToShortDateString(), Guid.NewGuid(), ".png"));

            MyImage.Save(filepathandname);

No comments:

Post a Comment