I'm using MVC with Web Api. I'm saving my image Path to DB. this is code I have written in web Api.

public int AddToolItem(ToolItem toolItem, HttpPostedFileBase toolItemImage)
        {
            var fileName = Path.GetFileName(toolItemImage.FileName);
            var path = Path.Combine(HttpContext.Current.Server.MapPath("~/Upload/ItemImage/"), fileName);
            toolItemImage.SaveAs(path);
            toolItem.ToolItemImage = path;

            dbContext.ToolItems.Add(toolItem);
            return dbContext.SaveChanges();
        }

It save the physical path of image

eg."E:\lifeexpress\rar\LifeExp\LifeExp\LifeExp.Web\Upload\ItemImage\images.jpg".

But when I'm retrieving, and Displaying in my mvc view page, Image is not showing .

<img src="@toolItem.ToolItemImage" /> 

It rendering the image as

<img src="E:\lifeexpress\rar\LifeExp\LifeExp\LifeExp.Web\Upload\ItemImage\images.jpg">

How can I show the image.

Related posts

Recent Viewed