当前位置:编程学习 > asp >>

无组件上传类的源代码

<SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>
'定义全局变量保存用户上传的内容'
dim strmUpload
'自定义class处理上传文件'
Class FileUpload
dim Form,File
Private Sub Class_Initialize
dim iStart,iFileNameStart,iFileNameEnd,iEnd,vbEnter,iFormStart,iFormEnd,theFile
dim strDiv,mFormName,mFormValue,mFileName,mFileSize,mFilePath,iDivLen,mStr
if Request.TotalBytes<1 then Exit Sub
set Form=CreateObject("Scripting.Dictionary")
set File=CreateObject("Scripting.Dictionary")
set strmUpload=CreateObject("Adodb.Stream")
strmUpload.mode=3
strmUpload.type=1
strmUpload.open
strmUpload.write Request.BinaryRead(Request.TotalBytes)
'vbscript中的换行符字符串'
vbEnter=Chr(13)&Chr(10)
'换行符的位置'
iDivLen=InStrB(1,vbEnter)+1
'表单中不同控件数据的分隔字符串'
strDiv=SubStrB(1,iDivLen)
'表单有效数据开始位置'
iFormStart=iDivLen
'表单有效数据结束位置'
iFormEnd=InStrB(iformStart,strDiv)-1
'循环得到表单中所有控件的值'
while iFormStart < iFormEnd
'得到控件的name'
iStart=InStrB(iFormStart,"name=""")
iEnd=InStrB(iStart+6,"""")
mFormName=SubStrB(iStart+6,iEnd-iStart-6)
'得到file控件的filename'
iFileNameStart=InStrB(iEnd+1,"filename=""")
'如果是file控件'
if iFileNameStart>0 and iFileNameStart<iFormEnd then
iFileNameEnd=InStrB(iFileNameStart+10,"""")
mFileName=SubStrB(iFileNameStart+10,iFileNameEnd-iFileNameStart-10)
iStart=InStrB(iFileNameEnd+1,vbEnter&vbEnter)
iEnd=InStrB(iStart+4,vbEnter&strDiv)
'如果上传了文件'
if iEnd>iStart then
'得到上传文件的大小'
mFileSize=iEnd-iStart-4
else
mFileSize=0
end if
set theFile=new FileInfo
补充:asp教程,脚本编码
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,