图片数据的存和取示例

2016-01-29 17:20 6 1 收藏

图片数据的存和取示例,图片数据的存和取示例

【 tulaoshi.com - ASP 】

  图片数据存入数据库:
        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("preview")<"yes" then
                sqlstr="update "&tbname&" set downtimes=downtimes+1 where id="&fileid
                conn.Execute sqlstr
            end if
    end if
说明:
对于超长的二进制数据(如图像数据)要使用fieldn

来源:https://www.tulaoshi.com/n/20160129/1501023.html

延伸阅读
    (一)原理 小偷程序实际上是通过了XML中的XMLHTTP组件调用其它网站上的网页。比如新闻小偷程序,很多都是调用了sina的新闻网页,并且对其中的html进行了一些替换,同时对广告也进行了过滤。用小偷程序的优点有:无须维护网站,因为小偷程序中的数据来自网站,它将随着该网站的更新而更新;可以节省资源,...
标签: Web开发
函数 语法 说明 示例 Now Now() 取得系统当前的日期和时间 Dim MyVar MyVar = Now '' MyVar 包含当前的日期和时间。 Date Date() 取得系统当前的日期 Dim MyDate MyDate = Date '' MyDate 包含当前系统日期。 Time Time() 取得系统当前的时间 Dim MyTime MyTime = Time '' 返回当前...
标签: Web开发
1、引言 数据库应用程序,特别是基于WEB的数据库应用程序,常会涉及到图片信息的存储和显示。通常我们使用的方法是将所要显示的图片存在特定的目录下,在数据库中保存相应的图片的名称,在JSP中建立相应的数据源,利用数据库访问技术处理图片信息。但是,如果我们想动态的显示图片,上述方法就不能满足需要了。我们必须把图片存入数据库,然后...
标签: Web开发
添加和删除HTML节点的简单示例 input type="button" onclick="appendnode()" value="添加节点" input type="button" onclick="removenode()" value="删除节点" div id="result"/div script i=0 function appendnode() { o=document.createElement("DIV"); o.innerHTML="test"+i document.getElementById('result').appendChild(o); i+...
Eclipse 是一个很让人着迷的开发环境,它提供的核心框架和可扩展的插件机制给广大的程序员提供了无限的想象和创造空间。目前网上流传相当丰富且全面的开发工具方面的插件,但是Eclipse已经超越了开发环境的概念,可以想象Eclipse将成为未来的集成的桌面环境。!-- frame contents -- !-- /frame contents --目前的Eclipse本身就具备资源治理和...

经验教程

606

收藏

66
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部