“Uid=xxxx;Pwd=xxxx;DataBase=DataBaseName”
imgConn.open strConn
Set Rs= Server.CreateObject(“ADODB.RecordSet”)
Sql=”Select * From img Where id is null” Rs.open sql,imgConn,1,3
‘追加数据到数据库
Rs.AddNew
Rs(“img”).AppendChunk myData
Rs.Update
‘关闭和释放对象
Rs.close
ImgConn.close
Set Rs=Nothing
Set ImgConn=Nothing
%〉
2) ShowImg.asp文件代码:
〈%
Response.Expires = 0
Response.buffer=True
Response.clear
‘创建对象实例
Set imgConn=Server.CreateObject(“ADODB.Connection”)
StrConn=”Driver={SQL Server};Server=ServerName;”& _
“Uid=xxxx;Pwd=xxxx;DataBase=DataBaseName”
imgConn.open strConn
Set Rs= Server.CreateObject(“ADODB.RecordSet”)
Sql=”Select img From img Where id=1” 这里的id可以使用Request(“id”)获得
Rs.open sql,imgConn,1,1
Response.ContentType=”image/*”
Response.BinaryWrite Rs.(“img”).GetChunk(7500000)
‘关闭和释放对象
Rs.close
ImgConn.close
Set Rs=Nothing
Set ImgConn=Nothing
%〉
至此,本文对如何使用ASP上传图片的原理和示例都讲完了,有什么不妥的地方请各位指正,谢谢!同时希望本文能够确实能为需要这方面帮助的网友提供实质性的帮助。(csdn上一页 [1] [2] |
|