1

I am using this example to display images, stored in my File-Stream Enabled database in a blob format.

http://support.microsoft.com/kb/173308

This is working perfect, but I am very bad in classic asp and have problem when try to display this images mix with HTML elements.

From my test and tries, I have concluded that this is because the Response.ContentType.

In the example above, to display the image they are using a content type of the image. Perfect. I have this in my database, too. But when I read it from there and change it in the asp file, the whole HTML in the asp file is not displayed.

What should I do in order to display my images mixed with HTML tags. This is part of my poor asp code, which will display only one picture form the database and no other HTML.

SQL = "SELECT RecordID FROM InfoTable"

Set Recordset = Server.CreateObject("ADODB.Recordset")

Recordset.Open SQL,AdapterDataBaseActiveConnection

If Recordset.EOF Then

    Response.Write("No records returned.")

Else

    Do While NOT Recordset.Eof  

        Set CurrentNumber=Recordset("RecordID") 

        'Response.write CurrentNumber
        'Response.write "<br>" 
        Set rs = AdapterDataBaseActiveConnection.Execute("SELECT ContentType FROM InfoTable WHERE RecordID="&CurrentNumber)
        Set CurrentContentType=rs("ContentType")

        'Response.write CurrentContentType
        Response.Expires = 0
        Response.Buffer = TRUE
        Response.Clear
        Response.ContentType = CurrentContentType

        Set rsa = AdapterDataBaseActiveConnection.Execute("SELECT RecordBLOB FROM ImageTable  WHERE RecordID="&CurrentNumber)
        'Response.write "<div>"
        Response.BinaryWrite rsa("RecordBLOB")
        'Response.write "</div>" 

        Recordset.MoveNext 

    Loop

End If      

My final goal is to put the blob data into "" tags. Is this possible?Maybe I should use some type of conversion? I have thought about this, and given up. I have just try to display the images in "" tags but not succeeded too.

Please, give me some advice about how should I approach in this situation.

Thank you in advance.

gotqn
  • 42,737
  • 46
  • 157
  • 243

1 Answers1

2

Typically it works this way:

This is the image in the page <img src="imageServer.asp?ID=1234">

The server answers the ONE request, sets the MIME header and streams the image data for this particular image. You are not outputting HTML, the html is in the page already. You need to tell the img tag where to get its data.

See: Display JPEG using Response.BinaryWrite

Community
  • 1
  • 1
Diodeus - James MacFarlane
  • 112,730
  • 33
  • 157
  • 176