图片显示!50分求!!!!!!!!!!!!

liyunqi 2004-08-01 08:45:20
我在数据库中有一个项目的字段,一个项目有可能有一个图片对应,也有可能有2个图片,但最多就三个,现在我想从库中把他们显示出来、有一个、就显示一个、,有几个就显示几个、!!

show.asp
<!--#include file="../conn/conn1.asp" -->
<%
id=(trim(request("id")))
if id="" then response.End
response.Expires=0
response.buffer=true
response.Clear()
set rs=server.CreateObject("adodb.recordset")
sql="select * from aa where productid="&ss&""
rs.open sql,conn,3,1
response.ContentType="image/*"



response.BinaryWrite rs("pic1")
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
显示的图片的页面:picshow.asp
<img src="show.asp?id=<%=rs("pic1")%>&dd=1" width="400" height="300" border="0" >
<img src="show.asp?id=<%=rs("pic1")%>&dd=1" width="400" height="300" border="0" >
<img src="show.asp?id=<%=rs("pic1")%>&dd=1" width="400" height="300" border="0" >
请问这个程序该怎么写???
答案正确立即结贴!
...全文
101 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
3573745 2004-08-01
  • 打赏
  • 举报
回复
你这个最好是前面已经把图片的名称寸到数据库中间
然后你把数据库中间的名称显示出来就是了
就没有必要用到FSO
问题就边成了一个很简单的了啊
Jaron 2004-08-01
  • 打赏
  • 举报
回复
以下代码支持所有数据库存储的文件,请作适当修改。

<!--#include file="cms-server/inc/conn.asp"-->
<%
on error resume next
set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from tblBinFiles where FileID='" & checkstr(request("FileID")) &"'"
rs.open sql,conn,1,3
if not(rs.EOF and rs.BOF or isnull(rs("Bin"))) then
Response.ContentType = getContentType(rs("FileExt"))
if GetFileType(rs("fileext")) <> 1 then Response.AddHeader "content-disposition", "attachment; filename=SiteManager_" & rs("FileID")
Response.BinaryWrite rs("Bin").getChunk(7500000)
Response.Flush
response.Clear()
viewtimes = rs("viewtimes") + 1
rs.Update
rs("viewtimes") = viewtimes
rs.Update
else
Response.Write "无效的数据格式"
end if
rs.close
set rs=nothing
Response.Write Err.Description
conn.close
set conn = nothing

function getContentType(fileExt)
Select Case lcase(FileExt)
Case "asf"
ContentType = "video/x-ms-asf"
Case "avi"
ContentType = "video/avi"
Case "doc"
ContentType = "application/msword"
Case "zip"
ContentType = "application/zip"
Case "xls"
ContentType = "application/vnd.ms-excel"
Case "gif"
ContentType = "image/gif"
Case "jpg", "jpeg"
ContentType = "image/jpeg"
Case "wav"
ContentType = "audio/wav"
Case "mp3"
ContentType = "audio/mpeg3"
Case "mpg", "mpeg"
ContentType = "video/mpeg"
Case "rtf"
ContentType = "application/rtf"
Case "htm", "html"
ContentType = "text/html"
Case "txt","asp","asa", "aspx", "asax"
ContentType = "text/plain"
Case Else
ContentType = "application/octet-stream"
End Select
getContentType = ContentType
end function

function GetFileType(fileext)
'判断文件类型
if lcase(fileExt)="gif" or lcase(fileExt)="jpg" or lcase(fileExt)="jpeg" or lcase(fileExt)="bmp" or lcase(fileExt)="png" then
GetFileType=1
elseif lcase(fileExt)="swf" or lcase(fileExt)="swi" then
GetFileType=2
elseif lcase(fileExt)="mid" or lcase(fileExt)="wav" or lcase(fileExt)="mp3" or lcase(fileExt)="rmi" or lcase(fileExt)="cda" then
GetFileType=3
elseif lcase(fileExt)="avi" or lcase(fileExt)="wov" or lcase(fileExt)="asf" or lcase(fileExt)="mpg" or lcase(fileExt)="mpeg" or lcase(fileExt)="ra" or lcase(fileExt)="ram" then
GetFileType=4
else
GetFileType=0
end if
end function

Function CheckStr(str)
If IsNull(str) Then
CheckStr = ""
Exit Function
End If
CheckStr = Replace(str, "'", "''")
End Function
%>

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧