用ASP代码实现图片上传并存入数据库中的问题
<formaction="images.asp"method="post"enctype="multipart/form-data"name="form1"id="for...
<form action="images.asp" method="post" enctype="multipart/form-data" name="form1" id="form1">
请上传你的图片:
<label>
<input type="file" name="file" />
</label>
<p>
<label>
<input type="submit" name="Submit" value="提交" />
</label>
</p>
</form>
<%
response.Buffer=true
formsize=request.TotalBytes
formdata=request.BinaryRead(formsize)
bncrlf=chrB(13) & chrB(10)
divider=leftB(formdata,clng(instrb(formdata,bncrlf))-1)
datastart=instrb(formdata,bncrlf & bncrlf)+4
dataend=instrb(datastart+1,formdata,divider)-datastart
mydata=midb(formdata,datastart,dataend)
dim con
set con=server.CreateObject("adodb.connection")
con.connectionstring="driver={microsoft access driver (*.mdb)};dbq=" & server.MapPath("image.mdb")
con.open
dim rec
set rec =server.CreateObject("adodb.recordset")
rec.Open "SELECT * FROM [表1] where id is null",con,1,3
rec.addnew
rec("图像").appendchunk mydata
rec.update
response.write "上传图片成功!"
set rec =nothing
set con =nothing
%>
用ASP代码实现图片上传并存入数据库中
而我这样得到的插入数据库中的并不是图片,而是"长二进制数据",怎么样才能够使数据存储的是图像
怎么样修改呢?? 展开
请上传你的图片:
<label>
<input type="file" name="file" />
</label>
<p>
<label>
<input type="submit" name="Submit" value="提交" />
</label>
</p>
</form>
<%
response.Buffer=true
formsize=request.TotalBytes
formdata=request.BinaryRead(formsize)
bncrlf=chrB(13) & chrB(10)
divider=leftB(formdata,clng(instrb(formdata,bncrlf))-1)
datastart=instrb(formdata,bncrlf & bncrlf)+4
dataend=instrb(datastart+1,formdata,divider)-datastart
mydata=midb(formdata,datastart,dataend)
dim con
set con=server.CreateObject("adodb.connection")
con.connectionstring="driver={microsoft access driver (*.mdb)};dbq=" & server.MapPath("image.mdb")
con.open
dim rec
set rec =server.CreateObject("adodb.recordset")
rec.Open "SELECT * FROM [表1] where id is null",con,1,3
rec.addnew
rec("图像").appendchunk mydata
rec.update
response.write "上传图片成功!"
set rec =nothing
set con =nothing
%>
用ASP代码实现图片上传并存入数据库中
而我这样得到的插入数据库中的并不是图片,而是"长二进制数据",怎么样才能够使数据存储的是图像
怎么样修改呢?? 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询