一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

纯ASP上传图像文件到数据库的最佳例子

时间:2022-06-30 11:17:51 编辑:袖梨 来源:一聚教程网

IAmTrue 发表于2000-11-2 7:56:49 ASP地带
getfile.htm
-------------------------


保存图片到数据库</a>



你可以找个图片试试,保存完毕后会有提示



Email :

Picture :





savetodb.asp
----------------------------------
<%
Response.Buffer = TRUE
Response.Clear
byteCount = Request.TotalBytes
RequestBin = Request.BinaryRead(byteCount)
Dim UploadRequest
Set UploadRequest = CreateObject("Scripting.Dictionary")
BuildUploadRequest RequestBin
email = UploadRequest.Item("email").Item("Value")
contentType = UploadRequest.Item("blob").Item("ContentType")
filepathname = UploadRequest.Item("blob").Item("FileName")
filename = Right(filepathname,Len(filepathname)-InstrRev(filepathname,""))
picture = UploadRequest.Item("blob").Item("Value")
'Response.ContentType = contentType
'Response.binaryWrite picture
set objCn = server.createobject("adodb.connection")
set objRst = server.createobject("adodb.recordset")
objCn.Open "upload"
objrst.Open "pic", objcn, 1,3,2
objrst.addnew
objrst.fields("filename")=filename
objrst.fields("type")="gif"
objrst.fields("what").appendchunk picture
objrst.update
response.write "第" & objrst("id") & "个图片。"

热门栏目