problem with retrieve image from database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alexseow
    New Member
    • Dec 2007
    • 6

    problem with retrieve image from database

    <img src="image.asp? id=1">

    ---------------------------------------------------------------
    <%Option Explicit%>
    <!-- #include file="IMS/includes/dbconn.asp"-->

    <%

    dim MyConn,SQL
    Set MyConn = Server.CreateOb ject("ADODB.Con nection")
    MyConn.Open dbConn
    SQL = "SELECT pic,name,size FROM img where id="& Request.QuerySt ring("id")
    Set rs =MyConn.Execute ( SQL )
    while not rs.eof then
    response.Conten tType="image/jpeg"
    Response.AddHea der "Content-Disposition", "attachment;fil ename=" & Trim(rs("name") )
    Response.AddHea der "Content-Length", rs("size")
    Response.Binary Write rs("pic")
    rs.MoveNext
    wend

    rs.close
    set rs=nothing

    %>
    ----------------------------------------------------------
    I managed to insert image into MySQL database but i can't retrieve. Any ASP expert can help me? . Thanks
  • jagged
    New Member
    • Feb 2008
    • 23

    #2
    What error are you getting?

    Personally I've never used the Response.AddHea der "Content-Disposition", "attachment;fil ename=" & Trim(rs("name") )
    Response.AddHea der "Content-Length", rs("size") when outputting images so you can try to comment them out and see if that helps.

    I would also remove the loop. Im not sure outputting two images one after the other would work, so just check if rst.eof = true.

    Comment

    • CroCrew
      Recognized Expert Contributor
      • Jan 2008
      • 564

      #3
      Hello alexseow,

      Here is an example using an Oracle server http://www.narfle.com/ref/asp/oracleBlob.asp that might help you out.

      Hope you find your answer~

      Comment

      • Karthikkommandi
        New Member
        • Apr 2008
        • 1

        #4
        Hi

        I am also getting similar type of problem.
        for retriving imgaes i am also using similar code. But i am getting Grabage values in web browser. It seems that it is displaying all binary data. like this...
        [
        ÿØÿàJFIF``ÿ í Photoshop 3.08BIMí Resolution`` 8BIM FX Global Lighting Anglex8BIMF X Global Altitude8BIM ó Print Flags 8BIM Copyright Flag8BIM'..... ........
        ]

        can anybody help me regarding this issue. as i am new to asp i am not able to fix this issue. Thanks in advance

        Comment

        Working...