数据上传与数据库问题

隐者神归 2003-10-22 09:45:02
我作了一个文件上传的表单,只有文件一项,提交的数据直接appendchunk到字段里就可以,但是把提交的数据一处理,数据到库里就不对了,少了,网上各种无组件上传试了,不知道为什么。哪位大侠帮助解决,500相送,代码如下:
<SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>
miid=Request.QueryString("i_id")

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)

Set imgConn=Server.CreateObject("ADODB.Connection")

StrConn="Provider=SQLOLEDB.1;USER ID=sa;Password=82015388;Initial Catalog=ctr_bbs;Data Source=(Local)"
imgConn.open strConn

Set Rs= Server.CreateObject("ADODB.RecordSet")



Sql="Select c_file,m_file,c_type From t_title Where i_id=" & miid
Rs.open sql,imgConn,1,3
Rs.FIELDS("m_file").AppendChunk myData '如果直接appendchunk formdata就没问题

Rs.Update

'关闭和释放对象

Rs.close

ImgConn.close

Set Rs=Nothing

Set ImgConn=Nothing
</script>
...全文
37 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
隐者神归 2003-10-22
  • 打赏
  • 举报
回复
yu1449@sohu.com
lihua9666 2003-10-22
  • 打赏
  • 举报
回复
我有类似你这样的源码,测试过没问题,给我你的邮箱我发给你
jiank 2003-10-22
  • 打赏
  • 举报
回复
dim RequestData,sStart,vbCrlf,sInfo,iInfoStart,iInfoEnd,tStream,iStart,theFile
dim iFileSize,sFilePath,sFileType,sFormValue,sFileName
dim iFindStart,iFindEnd
dim iFormStart,iFormEnd,sFormName
set objForm=Server.CreateObject("Scripting.Dictionary")
set objFile=Server.CreateObject("Scripting.Dictionary")
set tStream = Server.CreateObject("adodb.stream")
set data_stream = Server.CreateObject("adodb.stream")
data_stream.Type = 1
data_stream.Mode =3
data_stream.Open
data_stream.Write Request.BinaryRead(Request.TotalBytes)
data_stream.Position=0
RequestData =data_stream.Read
iFormStart = 1
iFormEnd = LenB(RequestData)
vbCrlf = chrB(13) & chrB(10)
sStart = MidB(RequestData,1, InStrB(iFormStart,RequestData,vbCrlf)-1)
iStart = LenB (sStart)
iFormStart=iFormStart+iStart+1
while (iFormStart + 10) < iFormEnd
iInfoEnd = InStrB(iFormStart,RequestData,vbCrlf & vbCrlf)+3
tStream.Type = 1
tStream.Mode =3
tStream.Open
data_stream.Position = iFormStart
data_stream.CopyTo tStream,iInfoEnd-iFormStart
tStream.Position = 0
tStream.Type = 2
tStream.Charset ="gb2312"
sInfo = tStream.ReadText
tStream.Close
'取得表单项目名称'
iFormStart = InStrB(iInfoEnd,RequestData,sStart)
iFindStart = InStr(22,sInfo,"name=""",1)+6
iFindEnd = InStr(iFindStart,sInfo,"""",1)
sFormName = lcase(Mid (sinfo,iFindStart,iFindEnd-iFindStart))
'如果是文件'
if InStr (45,sInfo,"filename=""",1) > 0 then
set theFile=new FileInfo
'取得文件名'
iFindStart = InStr(iFindEnd,sInfo,"filename=""",1)+10
iFindEnd = InStr(iFindStart,sInfo,"""",1)
sFileName = Mid (sinfo,iFindStart,iFindEnd-iFindStart)
theFile.FileName=getFileName(sFileName)
theFile.FilePath=getFilePath(sFileName)
'取得文件类型'
iFindStart = InStr(iFindEnd,sInfo,"Content-Type: ",1)+14
iFindEnd = InStr(iFindStart,sInfo,vbCr)
theFile.FileType =Mid (sinfo,iFindStart,iFindEnd-iFindStart)
theFile.FileStart =iInfoEnd
theFile.FileSize = iFormStart -iInfoEnd -3
theFile.FormName=sFormName
if not objFile.Exists(sFormName) then
objFile.add sFormName,theFile
end if
else
'如果是表单项目'
tStream.Type =1
tStream.Mode =3
tStream.Open
data_stream.Position = iInfoEnd
data_stream.CopyTo tStream,iFormStart-iInfoEnd-3
tStream.Position = 0
tStream.Type = 2
tStream.Charset ="gb2312"
sFormValue = tStream.ReadText
tStream.Close
if objForm.Exists(sFormName) then
objForm(sFormName)=objForm(sFormName)&", "&sFormValue else
objForm.Add sFormName,sFormValue
end if
end if
iFormStart=iFormStart+iStart+1
wend
RequestData=""
set tStream =nothing

下面还要写吗?
隐者神归 2003-10-22
  • 打赏
  • 举报
回复
怎么没人回答啊?
隐者神归 2003-10-22
  • 打赏
  • 举报
回复
tigerwen01(小虎)(编程艺术化) ,不是这个问题
tigerwen01 2003-10-22
  • 打赏
  • 举报
回复
...
Sql="Select c_file,m_file,c_type From t_title Where i_id=" & miid
Rs.open sql,imgConn,1,3
Rs.AddNew '加上这一句
Rs.FIELDS("m_file").AppendChunk myData '如果直接appendchunk formdata就没问题

Rs.Update

...

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧