ASP

本类阅读TOP10

·asp常用数据库连接方法和技巧
·无组件生成BMP验证码
·一些常用的辅助代码 (网络收藏)
·JavaScript实现的数据表格:冻结列、调整列宽和客户端排序
·VisualStudio.NET_2003及其 MSDN 下载地址
·ASP模拟MVC模式编程
·图片以二进制流输出到网页
·MD5加密算法 ASP版
·ASP.NET编程中的十大技巧
·改进 ASP 的字符串处理性能

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
一个图片数据的存和取的示例

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

一个图片数据的存和取的示例

图片数据存入数据库:
        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
说明:
对于超长的二进制数据(如图像数据)要使用fieldname.AppendChunk() 和fieldname.GetChunk()来读写。


 




相关文章

相关软件