zSynopsis
zSynopsis

Reputation: 4854

Display Image from a Network Directory in a Web Page

We currently have a store of images on a network directory and the path to those images stored in a db. I have a web app that needs to display these images to the users and i was wondering if this was possible and how i should i go about doing something like this.

Thanks

Upvotes: 0

Views: 499

Answers (1)

spender
spender

Reputation: 120528

public ActionResult GetImage(string imageName)
{
    return File(dirPath+imageName,"image/jpeg"); //or other mime type
}

Make sure you perform decent validation on imageName so that you don't accidentally expose parts of your filesystem you'd rather not. For instance if imageName is ..\..\web.config (for instance), you're in trouble.

Upvotes: 1

Related Questions