改变图片上传处理文件后出现错误~~
数据库中 pic_head 标题字段, pic_body具体内容字段, img图片字段(OLE)
我的图片上传代码:
upload.asp
<form action="upload_save.asp" method="post" enctype="multipart/form-data">
<input type="file" name="imgurl">
<input type="submit" name=ok value="ok">
</form>
上面的代码,我加上了可以可以上传标题文字的和内容的功能,如下
<form action="upload_save.asp" method="post" enctype="multipart/form-data">
<table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>标题</td>
<td><input name="pic_head" type="text" id="pic_head" /></td>
</tr>
<tr>
<td>内容</td>
<td><textarea name="pic_body" id="pic_body"></textarea></td>
</tr>
</table>
<input type="file" name="imgurl">
<input type="submit" name=ok value="ok">
</form>
图片上传处理文件upload_save.asp
<!--#include file="conn.asp"-->
<%
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)
set rs=server.createobject("ADODB.recordset")
rs.open "SELECT * FROM imgurl",conn,3,3
rs.addnew
rs("img").AppendChunk myData
rs.update
rs.close
set rs=nothing
set conn=nothing
response.redirect "admin_index.asp"
%>
改成了
<!--#include file="conn.asp"-->
<%
pic_head=request.form("pic_head")
pic_body=request.form("pic_body")
exec="insert into news(pic_head,pic_body) values('"+pic_head+"','"+pic_body+"')"
conn.execute exec
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)
set rs=server.createobject("ADODB.recordset")
rs.open "SELECT * FROM imgurl",conn,3,3
rs.addnew
rs("img").AppendChunk myData
rs.update
rs.close
set rs=nothing
set conn=nothing
response.redirect "admin_index.asp"
%>
加粗部分为改动部分,改变后显示错误~ 请教大家是怎么回事啊?