I have this method to convert an image to a base 64 string and then assign it from JQuery to an image type tag... but I realized that it is only encoding the path of the image, when I decode I get something like this:
ClientApp/dist/assets/ProfileImageGirls/Avatar_56106a30-ce82-452e-9bfc-3861a1fc9069.JPG
How can I solve it?
Method:
public string CodeBase64(string path)
{
string cadenaBase64 = string.Empty;
using (Image image = Image.FromFile(path))
{
using (MemoryStream m = new MemoryStream())
{
image.Save(m, image.RawFormat);
byte[] imageBytes = m.ToArray();
cadenaBase64 = Convert.ToBase64String(imageBytes);
}
}
return cadenaBase64;
}
I tried the code you posted and it works.
In case it is of interest, I share the code that I use to convert any file to Base64.