三度网教程:是一个免费提供流行视频软件教程、在线学习分享的学习平台!

图片数据的存与取示例

时间:2022-10-2作者:未知来源:三度网教程人气:


图片数据存入数据库:
        sqlstr="select * from "&tbname&" where id is null"
        set rs=server.createobject("adodb.recordset")
        rs.Open sqlstr,conn,1,3
        rs.AddNew ()
        rs("title")=title
        rs("filename")=filename
        rs("filetype")=filetype
        rs("thelevel")=thelevel
        rs("uploaddate")=date()
        rs("uploadip")=request.ServerVariables("REMOTE_ADDR")
        rs("contenttype")=contenttype
        rs("data").AppendChunk (binstr)
        rs("size")=size
        rs("offset")=offset
        rs.Update
        rs.Close()

读取显示:
    rs.Open sqlstr,conn,3
    if not rs.EOF then
            contenttype=rs("contenttype")
            binstr=rs("data").GetChunk(rs("size")+rs("offset"))
            if rs("offset")=1 then
                binstr=midb(binstr,2)
            end if
            if instr(contenttype,"text/")=1 or _
               instr(contenttype,"image/")=1 or _
               instr(contenttype,"application/msword")=1 then
                response.contenttype=trim(contenttype)
                response.binarywrite binstr
            else
                response.addheader "Content-Disposition","attachment;filename="""&rs("filename")&""""
                response.contenttype=trim(contenttype)
                response.binarywrite binstr
            end if
            if request("divview")<>"yes" then
                sqlstr="update "&tbname&" set downtimes=downtimes+1 where id="&fileid
                conn.Execute sqlstr
            end if
    end if
说明:
对于超长的二进制数据(如图像数据)要使用fieldname.AppendChunk() 和fieldname.GetChunk()来读写。

关键词:  图片数据的存与取示例





Copyright © 2012-2018 三度网教程(http://www.3du8.cn) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版