work with image asp net core and sql in asp.net code example
Example 1: Store Images In SQL Server Using EF Core And ASP.NET Core
public class Image
{
public int Id { get; set; }
public string ImageTitle { get; set; }
public byte[] ImageData { get; set; }
}
Example 2: asp net core image server
[HttpPost]
public ActionResult RetrieveImage()
{
Image img = db.Images.OrderByDescending
(i=>i.Id).SingleOrDefault();
string imageBase64Data =
Convert.ToBase64String(img.ImageData);
string imageDataURL =
string.Format("data:image/jpg;base64,{0}",
imageBase64Data);
ViewBag.ImageTitle = img.ImageTitle;
ViewBag.ImageDataUrl = imageDataURL;
return View("Index");
}