Displaying an image file that is not in the web directory

J

Javier

Hi all

does anyone know of a way to display an image that is not in the web directory, as a part of a page

Javier
 
V

vMike

You can set the img src tag to an aspx file ... say
getpic.aspx?_p=yourpicname ... and use something like this snip (not
tested).

Sub Page_Load(sender as object, e as eventArgs)
Response.ContentType = "image/jpeg"
dim strPics as string = Request.QueryString.Item("_p")
mgGenerateImage(strPics)
End Sub


Sub mgGenerateImage(strPics as string)
dim strNavPath as string = "c:\yournonwebpath\" 'probably want to store
setting in webconfig
dim myNewImage as system.drawing.image
try
myNewImage = New Bitmap(strNavPath & "strPics" & ".jpg")
mynewimage.Save(Response.OutputStream, ImageFormat.Jpeg)

catch
myNewImage = New Bitmap(strNavPath & "yourdefaultimage.jpg")
mynewimage.Save(Response.OutputStream, ImageFormat.Jpeg)

end try
mynewimage.dispose()
End Sub

You will need System.Drawing and System.Drawing.Imaging namespaces

Javier said:
Hi all,

does anyone know of a way to display an image that is not in the web
directory, as a part of a page?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top