How to show an image on my page

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default How to show an image on my page

    Hi folks,

    I use an access database with a textfield (ImagePathAndFile).
    In this textfield I store the full path to an image, for example:
    (C:\MyDB\Images\MyImage.jpg).

    Now I want to show this image in an asp page containing only one
    record. Do I need an Image or an ImageLink?

    I thought I put the textfield (ImagePathAndFile) on the form and
    try to retrieve the value for the Image, so everytime the image
    looks for the right image but I don't know how.

    Regards,

    MArco
    The Netherlands
    Krechting Guest

  2. Similar Questions and Discussions

    1. show hide image
      I have small image 40 x 20 pixel and i want to allow a swap image to appear that image is 200 x 100 pixel can u advise on the best way of doing it
    2. Image show when mouse over?
      Hi A image place holder is showing in the top left corner when the menu is moused over. Assuming you have show image place holders turned on in...
    3. Show image from SQL Image Field ?
      Hello: I've tried showing an image field from an MS SQL Server 2000 image field on an ASP page but All I get is this...
    4. how to show an image from database
      Carina wrote: I don't know if you can do it in PHP but what you want to do is write a separate page where you set the MIME type of the page to...
    5. how to show image retrieved from BLOB on the web page
      Hi, Does anyone know how to retrieve binary image data from BLOB column of SQL database table and show it on the web page. I know "img src=" tag...
  3. #2

    Default Re: How to show an image on my page

    I would strongly recommend storing the files in a folder that is accessible
    via the web, rather than c:\MyDB\Images\, you could use /images/. You could
    always build the full path if you need it by using server.mappath().

    Even with the full path, you could use a consistent string formatting
    function to strip off the unnecessary crap from the file path and swap the
    slashes around, and just say <img src="<%=fixImage(rs("ImagePath"))%>">

    The way it is now, you might have to do something like this:

    <img src=ImageUtility.asp?path=C:\MyDB\Images\MyImage.j pg>

    Where ImageUtility.asp looks like this:

    <%
    FilePath = Request.Querystring("path")
    Set FSO = CreateObject("Scripting.FileSystemObject")
    If FSO.FileExists(FilePath) Then
    Set ado = CreateObject("ADODB.Stream")
    ado.Open()
    ado.Type = 1
    ado.LoadFromFile(FilePath)
    Response.BinaryWrite ado.Read()
    Response.End
    %>

    Inefficient. Gross. PITA.




    "Krechting" <m.krechting@chello.nl> wrote in message
    news:a71c776d.0312251620.376a8510@posting.google.c om...
    > Hi folks,
    >
    > I use an access database with a textfield (ImagePathAndFile).
    > In this textfield I store the full path to an image, for example:
    > (C:\MyDB\Images\MyImage.jpg).
    >
    > Now I want to show this image in an asp page containing only one
    > record. Do I need an Image or an ImageLink?
    >
    > I thought I put the textfield (ImagePathAndFile) on the form and
    > try to retrieve the value for the Image, so everytime the image
    > looks for the right image but I don't know how.
    >
    > Regards,
    >
    > MArco
    > The Netherlands

    Foo Man Chew Guest

  4. #3

    Default Re: How to show an image on my page

    Tnx,

    But I still have some questions (I,m new in this)
    If i write this image utility will I then still be able to show the
    image in the same form as the rest of my record?
    Do I have to make an asp file just with that piece of code?
    Can't I just use <img src="<%=fixImage(rs("ImagePath"))%>">
    And what is fixImage in here?

    Sorry
    Marco



    "Foo Man Chew" <foo@man.chew> wrote in message news:<es887d0yDHA.2408@tk2msftngp13.phx.gbl>...
    > I would strongly recommend storing the files in a folder that is accessible
    > via the web, rather than c:\MyDB\Images\, you could use /images/. You could
    > always build the full path if you need it by using server.mappath().
    >
    > Even with the full path, you could use a consistent string formatting
    > function to strip off the unnecessary crap from the file path and swap the
    > slashes around, and just say <img src="<%=fixImage(rs("ImagePath"))%>">
    >
    > The way it is now, you might have to do something like this:
    >
    > <img src=ImageUtility.asp?path=C:\MyDB\Images\MyImage.j pg>
    >
    > Where ImageUtility.asp looks like this:
    >
    > <%
    > FilePath = Request.Querystring("path")
    > Set FSO = CreateObject("Scripting.FileSystemObject")
    > If FSO.FileExists(FilePath) Then
    > Set ado = CreateObject("ADODB.Stream")
    > ado.Open()
    > ado.Type = 1
    > ado.LoadFromFile(FilePath)
    > Response.BinaryWrite ado.Read()
    > Response.End
    > %>
    >
    > Inefficient. Gross. PITA.
    >
    >
    >
    >
    > "Krechting" <m.krechting@chello.nl> wrote in message
    > news:a71c776d.0312251620.376a8510@posting.google.c om...
    > > Hi folks,
    > >
    > > I use an access database with a textfield (ImagePathAndFile).
    > > In this textfield I store the full path to an image, for example:
    > > (C:\MyDB\Images\MyImage.jpg).
    > >
    > > Now I want to show this image in an asp page containing only one
    > > record. Do I need an Image or an ImageLink?
    > >
    > > I thought I put the textfield (ImagePathAndFile) on the form and
    > > try to retrieve the value for the Image, so everytime the image
    > > looks for the right image but I don't know how.
    > >
    > > Regards,
    > >
    > > MArco
    > > The Netherlands
    Krechting Guest

  5. #4

    Default Re: How to show an image on my page

    > Can't I just use <img src="<%=fixImage(rs("ImagePath"))%>">
    > And what is fixImage in here?
    fixImage would be a function that *would* turn your local path into a web
    path. However it doesn't seem like you've put your images in a place that
    is accessible to your web site, only your local hard drive.


    Foo Man Chew Guest

  6. #5

    Default Re: How to show an image on my page

    On 25 Dec 2003 16:20:57 -0800, [email]m.krechting@chello.nl[/email] (Krechting)
    wrote:
    >I use an access database with a textfield (ImagePathAndFile).
    >In this textfield I store the full path to an image, for example:
    >(C:\MyDB\Images\MyImage.jpg).
    Store the *relative* path and/or the URL for that image. And if you
    want it served via a web browser, make sure it's in your web folders
    or a virtual folder under the web folders.

    Jeff
    Jeff Cochran Guest

  7. #6

    Default Re: How to show an image on my page

    > (C:\MyDB\Images\MyImage.jpg).

    if this is for a web site, what are you doing putting those files in
    C:\MyDB\? What is MyDB? Put the files in your web structure, then you can
    just store the relative path, and then you can just say <img
    src=<%=rs("whatever")%>>

    when building a web site, stop thinking in terms of c:\


    freaky friday Guest

  8. #7

    Default Re: How to show an image on my page

    I use a local HD because I use a database that is also used on the machine
    I'm working in with a VB shell.
    But I already got the running on my local Harddrive.
    I made a imagelink and when I click on the link it goes to the local HD
    and shows the image in a new form, instead of what I want now in a image
    on the main form.

    regards
    Marco

    "freaky friday" <freaky@friday.net> wrote in message news:<OFzTDC9yDHA.2452@tk2msftngp13.phx.gbl>...
    > > (C:\MyDB\Images\MyImage.jpg).
    >
    > if this is for a web site, what are you doing putting those files in
    > C:\MyDB\? What is MyDB? Put the files in your web structure, then you can
    > just store the relative path, and then you can just say <img
    > src=<%=rs("whatever")%>>
    >
    > when building a web site, stop thinking in terms of c:\
    Krechting Guest

  9. #8

    Default Re: How to show an image on my page

    It is still not clear what your environment and expectations are.

    It the end-user (the one you want to see the image in the form) logged onto
    your local system with access rights to the image on your hard-drive? If
    not, exactly how to they get to the page containing the form (please show
    actual URL)?

    Typically, an image that is to appear in a web-page is referenced by an HTTP
    URL not a FILE URL. In order for this to happen the image must be in a
    directory mapped to a web site. You then build the URL by concatenating the
    path to the web site with the path to the file within the web site. For
    instance:

    web-site: [url]www.mysite.com[/url] mapped to C:\inetpub\wwwroot
    images directory: C:\inetpub\wwwroot\images

    Path to file pic.gif would be

    [url]http://www.mysite.com/images/pic.gif[/url]

    or you could use a relative path if the page containing the image were
    on [url]www.mysite.com[/url]

    /images/pic.gif


    --
    Mark Schupp
    Head of Development
    Integrity eLearning
    [url]www.ielearning.com[/url]


    "Krechting" <m.krechting@chello.nl> wrote in message
    news:a71c776d.0312281109.3a328514@posting.google.c om...
    > I use a local HD because I use a database that is also used on the machine
    > I'm working in with a VB shell.
    > But I already got the running on my local Harddrive.
    > I made a imagelink and when I click on the link it goes to the local HD
    > and shows the image in a new form, instead of what I want now in a image
    > on the main form.
    >
    > regards
    > Marco
    >
    > "freaky friday" <freaky@friday.net> wrote in message
    news:<OFzTDC9yDHA.2452@tk2msftngp13.phx.gbl>...
    > > > (C:\MyDB\Images\MyImage.jpg).
    > >
    > > if this is for a web site, what are you doing putting those files in
    > > C:\MyDB\? What is MyDB? Put the files in your web structure, then you
    can
    > > just store the relative path, and then you can just say <img
    > > src=<%=rs("whatever")%>>
    > >
    > > when building a web site, stop thinking in terms of c:\

    Mark Schupp Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139