Displaying an image file that is not in the web directory

Discussion in 'ASP .Net Web Controls' started by Javier, Feb 26, 2004.

  1. Javier

    Javier Guest

    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
     
    Javier, Feb 26, 2004
    #1
    1. Advertising

  2. Javier

    vMike Guest

    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" <> wrote in message
    news:...
    > 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
     
    vMike, Feb 27, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. http://www.visual-basic-data-mining.net/forum

    Displaying image after selecting an image file.

    http://www.visual-basic-data-mining.net/forum, Sep 15, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    369
    http://www.visual-basic-data-mining.net/forum
    Sep 15, 2004
  2. Dave
    Replies:
    1
    Views:
    9,852
    Steven Cheng[MSFT]
    Oct 24, 2005
  3. Guest
    Replies:
    1
    Views:
    565
    Andrea D'Onofrio [MSFT]
    May 21, 2004
  4. Kan Grewal

    Web Usercontrol in a Web Usercontrol not displaying...

    Kan Grewal, Jul 6, 2004, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    134
    Kan Grewal
    Jul 7, 2004
  5. Replies:
    1
    Views:
    135
    Bob Barrows [MVP]
    Jun 24, 2005
Loading...

Share This Page