A union of curiosity and data science

Knowledgebase and brain dump of a database engineer

Write Image to Browser as Base64 String

Embedded Image Objects

string myFilePath = @"<local file path>";

//write the filesystem image to the browser. 
FileStream file = File.OpenRead(myFilePath);
byte[] buffer = new byte[file.Length];
file.Read(buffer, 0, buffer.Length);
Response.Write("<img src =\"data:image/jpeg;base64," + Convert.ToBase64String(buffer) + "\" /> <br />");


Add comment