社区
ASP
帖子详情
>>>>上传二进制文件(比如word文档)到数据库后,如何从数据库中读取<<<<<
sq0421
2003-10-21 02:51:35
我通过上传图片文件到数据库的方法,可以把其他类型的文件也存到数据库image字段中,但采用原来的读图片的方法来读这样的数据
Response.ContentType = "image/*"
Response.BinaryWrite rs("file_content")
也能读,但文件类型就不对了,保存到硬盘上的文件扩展名为.asp
如何解决?????????????
...全文
53
4
打赏
收藏
>>>>上传二进制文件(比如word文档)到数据库后,如何从数据库中读取<<<<<
我通过上传图片文件到数据库的方法,可以把其他类型的文件也存到数据库image字段中,但采用原来的读图片的方法来读这样的数据 Response.ContentType = "image/*" Response.BinaryWrite rs("file_content") 也能读,但文件类型就不对了,保存到硬盘上的文件扩展名为.asp 如何解决?????????????
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
4 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
sq0421
2003-10-22
打赏
举报
回复
多谢二位,我是考虑到用文件的形式会被下载,用数据库的方式就比较安全。
gasover
2003-10-21
打赏
举报
回复
更正, 如果要下载的话,请把上面这句:Response.AddHeader "Content-Disposition", "filename=" &
改成:
Response.AddHeader "Content-Disposition", "attachment; filename=" &
heguowei
2003-10-21
打赏
举报
回复
用文件的方法多好,只存储文件的路径即可
gasover
2003-10-21
打赏
举报
回复
<%
Response.Buffer = true
Response.Clear
……
……
url=rs("url") '数据库操作,读出文件路径,存到变量url中
Set fso=Server.CreateObject("Scripting.FileSystemObject")
Set fl=fso.getfile(url)
flsize=fl.size
flName=fl.name
Set fl=Nothing
Set fso=Nothing
%>
<%
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = 1
objStream.LoadFromFile url
Select Case lcase(Right(flName, 4))
Case ".asf"
ContentType = "video/x-ms-asf"
Case ".avi"
ContentType = "video/avi"
Case ".doc"
ContentType = "application/msword"
Case ".zip"
ContentType = "application/zip"
Case ".xls"
ContentType = "application/vnd.ms-excel"
Case ".gif"
ContentType = "image/gif"
Case ".jpg", "jpeg"
ContentType = "image/jpeg"
Case ".wav"
ContentType = "audio/wav"
Case ".mp3"
ContentType = "audio/mpeg3"
Case ".mpg", "mpeg"
ContentType = "video/mpeg"
Case ".rtf"
ContentType = "application/rtf"
Case ".htm", "html"
ContentType = "text/html"
Case ".txt"
ContentType = "text/plain"
Case Else
ContentType = "application/octet-stream"
End Select
Response.AddHeader "Content-Disposition", "filename=" &
flName
Response.AddHeader "Content-Length", flsize
Response.Charset = "UTF-8"
Response.ContentType = ContentType
Response.BinaryWrite objStream.Read
Response.Flush
response.Clear()
objStream.Close
Set objStream = Nothing
%>
中
软国际Java基础课件Chapter.ppt
中
软国际Java基础课件Chapter.ppt
自动化生产线安装与调试全套课件.ppt
自动化生产线安装与调试全套课件.ppt
第9周小课用Matlab实现信号波形.ppt
第9周小课用Matlab实现信号波形.ppt
事故二叉树计算机算法.doc
事故二叉树计算机算法.doc
CAD第一单元课件.ppt
CAD第一单元课件.ppt
ASP
28,409
社区成员
356,971
社区内容
发帖
与我相关
我的任务
ASP
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
复制链接
扫一扫
分享
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章