Sammy
Sammy

Reputation: 15

How to view Images From the Folders in Server?

I have a list of images for users. In the database the images table has these columns:

  1. id
  2. height
  3. width
  4. fileName
  5. userName
  6. userId

I have uploaded these images to the server in a specific folder. Therefore, the only thing that should be done, is to search the folder for the correct fileName for the logged-in user, and fetch the image.

When I login and view the gallery, I'd like to see my image on the screen. I've searched for it a long time, but no answer till now.

Upvotes: 0

Views: 709

Answers (3)

Anyname Donotcare
Anyname Donotcare

Reputation: 11423

Not that clear question but i will try to solve it:

  1. Get the file name according to the userId by some query .and store it in an
    variable .

  2. string dir = System.Web.HttpContext.Current.Server.MapPath("~") + "/" + FolderName + "/" + FileNameVarWithExtinsion;

  3. Set the ImageUrl by the the previous path.

Upvotes: 0

megusta
megusta

Reputation: 134

is that folder under your web applications iis folder? if not you have to create a virtual directory to that folder, so you can call it by url. eg. http://<your host>/<images folder(virtual directory)>/<user id>.jpg

Upvotes: 1

KV Prajapati
KV Prajapati

Reputation: 94653

You can write ImageHandler to display images.

Upvotes: 1

Related Questions