Click here to Skip to main content
14,878,179 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i upload image in mvc database image stored in encrypt form when i retrieving image but image is not display ...

What I have tried:


<img src="@Url.Content(@item.resume)" height="25px" width="50px" />
Updated 23-Jun-18 5:27am
F-ES Sitecore 15-Feb-16 6:23am
What are you doing to decrypt the image and stream it to the client? What does item.resume return?
Member 12256508 16-Feb-16 3:10am
public ActionResult Index(upload upload,HttpPostedFileBase File)

if (File == null)
ModelState.AddModelError("File", "Please Upload Your file");
string filename = Guid.NewGuid() + Path.GetExtension(File.FileName);
File.SaveAs(Path.Combine(Server.MapPath("~/uploadcv"), filename));
using (NGOEntities1 db = new NGOEntities1())
upload.resume = filename;
upload = null;
ViewBag.message = "Succcess";

catch(Exception Ex)
ViewBag.message = "Error";
return View();
return RedirectToAction("list");
Richard Deeming 15-Feb-16 9:51am
Have you actually encrypted the image, or is it just stored as an array of bytes?
Member 12256508 16-Feb-16 3:11am
resume mens i upload image only ok...and database have stored encryp string ...only

when i retrive code like
public ActionResult list()
return View(db.uploads.ToList());
<img src="@Url.Content(@item.resume)" height="25px" width="50px" />

1 solution

Based on the code posted in the comments, you're missing the path of the file in the image tag:
<img src="@Url.Content("~/uploadcv/" + item.resume)" height="25px" width="50px" />

Or, if you're using MVC4 or higher:
<img src="~/uploadcv/@item.resume" height="25px" width="50px" />

However, the upload code you've posted doesn't seem to verify that the uploaded file is actually an image. If the user has uploaded a different file type - for example, a Word document - then you can't display it in an <img> tag.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900