好学IT学院:IT信息技术分享交流平台
标签:ASP  来源:互联网  作者:本站整理  发布时间:2007-01-12  ★★★加入收藏〗〖手机版
LyfUpload组件的全攻略
摘要:组件方法介绍:Request方法得到上一个页面中表单元素的值;声明:Public Function Request(nm As String)返回值:为元素的值,字符串类型;FileType方法得到上传文件的Content-Type声明:P……

3、从数据库中显示图形的asp页面(pictest.asp)
<%
Function SetForDisplay(field, contentType) ’设置文件的大小及MIME类型
contentType = LCase(trim(contentType))
nFieldSize = field.ActualSize
bytes = field.GetChunk(nFieldSize)
Session("Bytes") = bytes
Session("Type") = contentType
End Function
%>
<%
sql = "select * from product where id=" &request("ID")
Set oRS =Server.CreateObject("ADODB.Recordset")
oRS.CursorLocation = 3
strConn = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("new.mdb")
oRS.Open sql, strConn
SetForDisplay oRS("pic"),"image/gif" ’"image/gif"

为MIME类型
’附:常见的MIME类型
’GIF文件
"image/gif"
’BMP文件
"image/bmp"
’JPG文件
"image/jpeg"
’zip文件
"application/x-zip-compressed"
’DOC文件
"application/msword"
’文本文件
"text/plain"
’HTML文件
"text/html"
’一般文件
"application/octet-stream"
Set oRS.ActiveConnection = Nothing
%>
<javascript src="theImg.asp">
’调用处理页面
<%response.write(Session("Type"))%>

4、最后处理页面(theImg.asp)

<%
response.Expires = 0
response.Buffer = True
response.Clear
response.contentType = Session("Type")
response.BinaryWrite
Session("Bytes")
Session("Type") = ""
Session("Bytes") = ""
response.End
%>

  • 好学触屏公众号虎力全开、杨帆起航!
  • 四大名著全套小学生版注音版
  • 诗词中的科学全4册
  • 曹文轩系列儿童文学全套画本