DBPix Sample Source Code: thumb_.asp Back to sample
<% @ LANGUAGE=VBScript %>
<% Option Explicit %>
<%
' In a production system you may wish to allow a short or long time here, depending on the
' frequency of updates and how you assign Id's. Maximize use of caching if possible.
Response.Expires = 0
Response.Buffer = TRUE
Response.Clear
%>
<!--#include file="config.inc" -->
<%
Dim oConn
Dim oRs
Dim SQL
Dim m_sSourceID
' Setup HTTP Header Information so that the browser interprets
' the returned data as a graphic file. Note that browsers
' interpret returned information using MIME headers -- not file
' extensions.
Response.ContentType = "image/jpeg"
m_sSourceID = Request("imgid")
If (m_sSourceID <> "") Then
SQL = "SELECT tphotos.* " &_
"FROM tphotos " &_
"WHERE Id = " & m_sSourceID
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open GetConnectString
Set oRs = oConn.Execute(SQL)
' Write Data back to client. Because MIME type is set to
' image/jpeg, the browser will automatically render as picture
Response.BinaryWrite oRs("thumb").GetChunk(oRs("thumb").ActualSize)
' Cleanup:
oRs.Close
Set oConn = Nothing
Set oRs = Nothing
end if
Response.End
%>
Back to sample
|