今日收获:图片数据的存和取示例
2013-05-29 18:03
204 查看
图片数据存入数据库:
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()来读写。
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()来读写。
相关文章推荐
- jquery ajax 获取 后台传入base64 图片数据转成图片示例
- Android利用Volley异步加载数据(JSON和图片)完整示例
- Android利用Volley异步加载数据(JSON和图片)完整示例
- android创建数据库(SQLite)保存图片示例ZZ 分类: Android数据存储 2015-03-22 09:58 41人阅读 评论(0) 收藏
- node.js读取Excel数据(下载图片)的方法示例
- 一个图片数据的存和取的示例
- 分享Asp.net做的几个实用示例,数据报表、二维码、数据抓取、批量上传图片
- 今日收获总结(关于存储过程时间查询的一些方法以及字段截取的函数及调用示例)
- volley学习笔记(四):Android利用Volley异步加载数据(JSON和图片)完整示例
- PHP使用CURL向服务器POST文本数据和上传图片的代码示例
- phpcms v9用get-sql调用数据表中的图组图片示例代码
- 数据库操作_连接SQL Server数据库示例;连接ACCESS数据库;连接到 Oracle 数据库示例;SqlCommand 执行SQL命令示例;SqlDataReader 读取数据示例;使用DataAdapter填充数据到DataSet;使用DataTable存储数据库表;将数据库数据填充到 XML 文件;10 使用带输入参数的存储过程;11 使用带输入、输出参数的存储过程示;12 获得数据库中表的数目和名称;13 保存图片到SQL Server数据库示例;14 获得插入记录标识号;Exce
- Android利用Volley异步加载数据(JSON和图片)完整示例
- gridview布局示例二(通过simpleAdapter进行图片等数据绑定)
- Android利用Volley异步加载数据(JSON和图片)完整示例
- gridview布局示例二(通过simpleAdapter进行图片等数据绑定)
- Android利用Volley异步加载数据(JSON和图片)完整示例
- Android利用Volley异步加载数据(JSON和图片)完整示例
- ListView优化机制及滑动时数据时出现的数据错乱重复问题 图片、checkBox等
- kafka->spark->streaming->mysql(scala)实时数据处理示例