Tuesday, June 17, 2025

How to save bytes data to image

using memory stream

MemoryStream m = new MemoryStream(bytes); 

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

MyImage.Save(filepathandname)

====================

using fileupload control

fileUpload1.FileBytes;

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

MyImage.Save(filepathandname)

No comments:

Post a Comment