急!请问关于AspcnUP上传组件的使用??????????

qdubit 2003-01-09 05:36:47
我在网页上做了一个上传文件的链接,使用AspcnUP组件,我已经在机器上注册了,但是在使用的时候发现文件没法上传,不知道是什么原因?另外请告诉我怎么使用AspcnUP的属性Errors()???我想通过errors属性查看错误,谢了先!
...全文
48 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
梁无惧 2003-01-11
  • 打赏
  • 举报
回复
<SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>
'----------------------------------------------------------------------
'******************* 无组件上传类 ********************************
'修改者:梁无惧
'电子邮件:yjlrb@21cn.com
'网站:http://asp.25cn.com
'原作者:稻香老农
'原作者网站:http://www.5xsoft.com
'声明:此上传类是在化境编程界发布的无组件上传类的基础上修改的.
'在与化境编程界无组件上传类相比,速度快了将近50倍,当上传4M大小的文件时
'服务器只需要10秒就可以处理完,是目前最快的无组件上传程序,当前版本为0.93
'源代码公开,免费使用,对于商业用途,请与作者联系
'**********************************************************************
'----------------------------------------------------------------------
dim oUpFileStream

Class upload_file

dim Form,File,Version

Private Sub Class_Initialize
dim RequestBinDate,sStart,bCrLf,sInfo,iInfoStart,iInfoEnd,tStream,iStart,oFileInfo
dim iFileSize,sFilePath,sFileType,sFormValue,sFileName
dim iFindStart,iFindEnd
dim iFormStart,iFormEnd,sFormName
Version="无组件上传类 Version 0.93"
set Form=Server.CreateObject("Scripting.Dictionary")
set File=Server.CreateObject("Scripting.Dictionary")
if Request.TotalBytes<1 then Exit Sub
set tStream = Server.CreateObject("adodb.stream")
set oUpFileStream = Server.CreateObject("adodb.stream")
oUpFileStream.Type = 1
oUpFileStream.Mode =3
oUpFileStream.Open
oUpFileStream.Write Request.BinaryRead(Request.TotalBytes)
oUpFileStream.Position=0
RequestBinDate =oUpFileStream.Read
iFormStart = 1
iFormEnd = LenB(RequestBinDate)
bCrLf = chrB(13) & chrB(10)
sStart = MidB(RequestBinDate,1, InStrB(iFormStart,RequestBinDate,bCrLf)-1)
iStart = LenB (sStart)
iFormStart=iFormStart+iStart+1
while (iFormStart + 10) < iFormEnd
iInfoEnd = InStrB(iFormStart,RequestBinDate,bCrLf & bCrLf)+3
tStream.Type = 1
tStream.Mode =3
tStream.Open
oUpFileStream.Position = iFormStart
oUpFileStream.CopyTo tStream,iInfoEnd-iFormStart
tStream.Position = 0
tStream.Type = 2
tStream.Charset ="gb2312"
sInfo = tStream.ReadText
'取得表单项目名称
iFormStart = InStrB(iInfoEnd,RequestBinDate,sStart)
iFindStart = InStr(22,sInfo,"name=""",1)+6
iFindEnd = InStr(iFindStart,sInfo,"""",1)
sFormName = Mid (sinfo,iFindStart,iFindEnd-iFindStart)
'如果是文件
if InStr (45,sInfo,"filename=""",1) > 0 then
set oFileInfo=new FileInfo
'取得文件名
iFindStart = InStr(iFindEnd,sInfo,"filename=""",1)+10
iFindEnd = InStr(iFindStart,sInfo,"""",1)
sFileName = Mid (sinfo,iFindStart,iFindEnd-iFindStart)
oFileInfo.FileName=getFileName(sFileName)
oFileInfo.FilePath=getFilePath(sFileName)
'取得文件类型
iFindStart = InStr(iFindEnd,sInfo,"Content-Type: ",1)+14
iFindEnd = InStr(iFindStart,sInfo,vbCr)
oFileInfo.FileType =Mid (sinfo,iFindStart,iFindEnd-iFindStart)
oFileInfo.FileStart =iInfoEnd
oFileInfo.FileSize = iFormStart -iInfoEnd -3
oFileInfo.FormName=sFormName
file.add sFormName,oFileInfo
else
'如果是表单项目
tStream.Close
tStream.Type =1
tStream.Mode =3
tStream.Open
oUpFileStream.Position = iInfoEnd
oUpFileStream.CopyTo tStream,iFormStart-iInfoEnd-3
tStream.Position = 0
tStream.Type = 2
tStream.Charset ="gb2312"
sFormValue = tStream.ReadText
form.Add sFormName,sFormValue
end if
tStream.Close
iFormStart=iFormStart+iStart+1
wend
RequestBinDate=""
set tStream =nothing
End Sub

Private Sub Class_Terminate
if not Request.TotalBytes<1 then
form.RemoveAll
file.RemoveAll
set form=nothing
set file=nothing
oUpFileStream.Close
set oUpFileStream =nothing
end if
End Sub


Private function GetFilePath(FullPath)
If FullPath <> "" Then
GetFilePath = left(FullPath,InStrRev(FullPath, "\"))
Else
GetFilePath = ""
End If
End function

Private function GetFileName(FullPath)
If FullPath <> "" Then
GetFileName = mid(FullPath,InStrRev(FullPath, "\")+1)
Else
GetFileName = ""
End If
End function

End Class

Class FileInfo
dim FormName,FileName,FilePath,FileSize,FileType,FileStart
Private Sub Class_Initialize
FileName = ""
FilePath = ""
FileSize = 0
FileStart= 0
FormName = ""
FileType = ""
End Sub

Public function SaveToFile(FullPath)
dim oFileStream,ErrorChar,i
SaveToFile=1
if trim(fullpath)="" or right(fullpath,1)="/" then exit function
set oFileStream=CreateObject("Adodb.Stream")
oFileStream.Type=1
oFileStream.Mode=3
oFileStream.Open
oUpFileStream.position=FileStart
oUpFileStream.copyto oFileStream,FileSize
oFileStream.SaveToFile FullPath,2
oFileStream.Close
set oFileStream=nothing
SaveToFile=0
end function
End Class
</SCRIPT>
linday 2003-01-09
  • 打赏
  • 举报
回复
关注

28,390

社区成员

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

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