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.

3
  • 1
    +9000 for reminding me of 1995 :). Even in 'modern' technologies what you do is provide an 'src' to another page that copies the data directly to the output. You can't do it 'inline' - it has to come through another request. Commented Feb 8, 2012 at 22:19
  • 2
    Thank you for reminding me how old I am. :P Commented Feb 8, 2012 at 22:21
  • If you really want to do it inline you can appropriate the information in: webmasterworld.com/forum83/7473.htm Commented Feb 8, 2012 at 22:25

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.