I found the following code but unable to understand what should I pass through ImageToBase64(Image image, System.Drawing.Imaging.ImageFormat format).
I need a FileUpload tool to upload an image to system and to pass it to ImageToBase64
For reference my code is
public string ImageToBase64(Image image, System.Drawing.Imaging.ImageFormat format)
{
using (MemoryStream ms = new MemoryStream())
{
image.Save(ms, format);
byte[] imageBytes = ms.ToArray();
string base64String = Convert.ToBase64String(imageBytes);
return base64String;
}
}
I tried doing ImageToBase64(FileUpload.FileBytes, "Image/PNG") But I am getting syntax error. What’s the correct syntax that I can use to this code?
Because the function takes argument of type Image and ImageFormat, and you are passing in byte[] and string.
You don’t need mime type, and you would only need the