|
 |
asp_databases thread: displaying a sequence of images from a DB ??
Message #1 by "peter" <ph@t...> on Thu, 12 Oct 2000 00:36:05 +0100
|
|
the following code is to display a sequence of one to three images.
However, it will only display the first one and not the other two. Any
help, as always, greatly appreciated
cheers peter
<%
SQL = "select Image1, Image2, Image3, Seq_name from MYIMAGES where_
Seq_name='" & Request("Seq_name") & "'"
Set rs = Server.CreateObject("adodb.recordset")
rs.Open SQL, ConnectStr, 2, 3
If Not rs.EOF Then
Response.ContentType = "application/octet-stream"
Response.AddHeader "Content-Disposition", "Seq_name=" &
rs("Seq_name")
Response.BinaryWrite rs("Image1")
Response.BinaryWrite rs("Image2")
Response.BinaryWrite rs("Image3")
%>
Message #2 by "Ken Schaefer" <ken@a...> on Thu, 12 Oct 2000 18:06:07 +1000
|
|
I'm not sure you can do this...
Surely if you sent Content-disposition image/jpg then the browser will be
expecting code for a well-formed jpeg image? (as in a single jpeg image with
the necessary bits indicating where the image starts and where it ends?)
(I've just never seen a web-browser display three images, with nothing else)
Cheers
Ken
----- Original Message -----
From: "peter" <ph@t...>
To: "ASP Databases" <asp_databases@p...>
Sent: Thursday, October 12, 2000 9:36 AM
Subject: [asp_databases] displaying a sequence of images from a DB ??
> the following code is to display a sequence of one to three images.
> However, it will only display the first one and not the other two. Any
> help, as always, greatly appreciated
>
> cheers peter
>
> <%
>
> SQL = "select Image1, Image2, Image3, Seq_name from MYIMAGES where_
> Seq_name='" & Request("Seq_name") & "'"
>
> Set rs = Server.CreateObject("adodb.recordset")
> rs.Open SQL, ConnectStr, 2, 3
> If Not rs.EOF Then
> Response.ContentType = "application/octet-stream"
> Response.AddHeader "Content-Disposition", "Seq_name=" &
> rs("Seq_name")
> Response.BinaryWrite rs("Image1")
> Response.BinaryWrite rs("Image2")
> Response.BinaryWrite rs("Image3")
>
> %>
Message #3 by "peter" <ph@t...> on Thu, 12 Oct 2000 14:30:03 +0100
|
|
Well, somehow I need to get it to loop. Thing is the first image does get
displayed, The sql selects all three from the criteria...so logically it
seems ok, ..Ive tried various formats but no luck, any ideas on how I can
do this in any way would be great..
thanks
peter
Message #4 by Imar Spaanjaars <Imar@S...> on Thu, 12 Oct 2000 15:49:53 +0200
|
|
What you could do is encapsulate your logic in a separate asp page. For
example showImage.asp.
In that page, retrieve the image like you did before based on a QueryString
parameter.
For example:
Select Case Request.QueryString("IMAGENUMBER")
Case "1"
sSQL = SELECT IMAGE1 etc etc
' Retrieve from database etc.
Case "2"
sSQL = SELECT IMAGE2 etc etc
End select
Make sure that no other content than the image is written to the response
object. Also set the content type to the correct image format.
Then in your calling page, you can do this:
<IMG ID="1" SRC="/showImage.asp?IMAGENUMBER=1/>
<IMG ID="2" SRC="/showImage.asp?IMAGENUMBER=2/>
<IMG ID="3" SRC="/showImage.asp?IMAGENUMBER=3/>
This will render the three different images in your browser.
This might not be the most efficient way to do it (opening a recordset
three times), but it'll work.
In case your images don't change often, you might consider saving them to
disk first.
HtH
Imar
At 02:30 PM 10/12/2000 +0100, you wrote:
>Well, somehow I need to get it to loop. Thing is the first image does get
>displayed, The sql selects all three from the criteria...so logically it
>seems ok, ..Ive tried various formats but no luck, any ideas on how I can
>do this in any way would be great..
>
>thanks
>
>peter
>
Message #5 by "Jez" <ray@j...> on Thu, 12 Oct 2000 11:18:53 -0500
|
|
Thats was my first thought as well as to how this problem could be solved,
and indeed it would work. But to get around the 3 sql calls problem could
you use Content-Type: Multipart/Related; boundary=boundry1 ? and then send
your 3 graphics as 3 parts:
--boundry1
Content-Type: image/jpeg
response.binarywrite(oRs(1))
--boundry1
Content-Type: image/jpeg
response.binarywrite(oRs(2))
etc.....
would this work?
-----Original Message-----
From: Imar Spaanjaars [mailto:Imar@S...]
Sent: Thursday, October 12, 2000 8:50 AM
To: ASP Databases
Subject: [asp_databases] Re: displaying a sequence of images from a DB
??
What you could do is encapsulate your logic in a separate asp page. For
example showImage.asp.
In that page, retrieve the image like you did before based on a QueryString
parameter.
For example:
Select Case Request.QueryString("IMAGENUMBER")
Case "1"
sSQL = SELECT IMAGE1 etc etc
' Retrieve from database etc.
Case "2"
sSQL = SELECT IMAGE2 etc etc
End select
Make sure that no other content than the image is written to the response
object. Also set the content type to the correct image format.
Then in your calling page, you can do this:
<IMG ID="1" SRC="/showImage.asp?IMAGENUMBER=1/>
<IMG ID="2" SRC="/showImage.asp?IMAGENUMBER=2/>
<IMG ID="3" SRC="/showImage.asp?IMAGENUMBER=3/>
This will render the three different images in your browser.
This might not be the most efficient way to do it (opening a recordset
three times), but it'll work.
In case your images don't change often, you might consider saving them to
disk first.
HtH
Imar
At 02:30 PM 10/12/2000 +0100, you wrote:
>Well, somehow I need to get it to loop. Thing is the first image does get
>displayed, The sql selects all three from the criteria...so logically it
>seems ok, ..Ive tried various formats but no luck, any ideas on how I can
>do this in any way would be great..
>
>thanks
>
>peter
>
|
|
 |