hi,plz i need help for loading image saved at sql server from MVC 5.
i used to call $.ajax({ url: './cName '/OpenDocument/?id=' + dataRecord.DocumentID_PK, data: '', type: 'POST' });
public byte[] GetImageFromDataBase(int Id)
{
var q = from temp in db.VwDocuments where temp.DocumentID_PK == Id select temp.DocumentContent;
byte[] cover = q.First();
return cover;
}
public FileResult OpenDocument(int id)
{
try
{
byte[] cover = GetImageFromDataBase(id);
if (cover != null)
{
//return File(cover, "image/jpg");
return File(cover,"application/octetstream", "elementary19240001");
}
else
{
return null;
}