Answer the question
In order to leave comments, you need to log in
Switching from ASP Net to ASP Net Core?
Good day!
Need help in resolving the issue. There was a Net Framework 4.6 project in which the image was converted to an array of bytes and placed in the database. Conversion code:
public static byte[] imageToByteArray(string imagePath)
{
MemoryStream ms = new MemoryStream();
System.Drawing.Image.FromFile(imagePath).Save(ms, ImageFormat.Jpeg);
return ms.ToArray();
}
<img class="" src="data:image/jpeg;base64,@(Convert.ToBase64String(ps.GetImage(p.Id)))" alt="@p.Name">
Byte[] img = await Prods.GetImage(p.Id); //Функция получает массив байт и БД
string path = Path.Combine(uploads, p.Id.ToString() + ".jpg");
await System.IO.File.WriteAllBytesAsync(path, img.ToArray())
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question