如何从下面上传类中得到非文件域的表单的内容
<script language="VBScript" runat="server">
'此类在初始化时完成扫描
'此类不能处理有重名项的表单
Server.ScriptTimeOut = 600
Class QuickUpload
Private FForm, FFile, Upload_Stream
property get Form
set Form = FForm
end property
property get File
set File = FFile
end property
Private Sub Class_Initialize
dim iStart, iEnd, boundary, FieldName, FileName, ContentType, ItemValue, theFile
set FForm=CreateObject("Scripting.Dictionary")
set FFile=CreateObject("Scripting.Dictionary")
set Upload_Stream=CreateObject("Adodb.Stream")
Upload_Stream.mode=3
Upload_Stream.type=1
Upload_Stream.open
if Request.TotalBytes<1 then Exit Sub
dStart = CDbl(Time)
'dim nByte
'nByte = 65536
'do while nByte=65536
'Upload_Stream.write Request.BinaryRead(nByte)
'loop
'Response.Write "read time:" & (CDbl(Time)-dStart)*24*60*60 & "<br/>"
'dStart = CDbl(Time)
'查找第一个边界
'iStart=1
'boundary=GetALine(iStart)
iStart=GetAChunk(1, ChrB(13)&ChrB(10), false, null)
boundary=subString(1,iStart-2-1)
'不是结束边界,则循环
do while StrComp(subString(iStart-2,2),ChrB(45)&ChrB(45))<>0
'取表单项信息头
iStart = ParseHeader(iStart, FieldName, FileName, ContentType)
'取表单项内容
if FileName<>"" then
set theFile = new FileInfo
theFile.Init FileName, ContentType
set dest = theFile.Stream
iNewStart=GetAChunk(iStart, boundary, true, dest)
FFile.add FieldName, theFile
else
iNewStart=GetAChunk(iStart, boundary, false, null)
FForm.Add FieldName, ByteToStr(subString(iStart,iNewStart-iStart-LenB(boundary)-2))
end if
iStart = iNewStart+2
loop
Response.Write "parse time:" & (CDbl(Time)-dStart)*24*60*60 & "<br/>"
End Sub
private function ParseHeader(theStart, byref FieldName, byref FileName, byref ContentType)
iStart = theStart
do while true
'取一行
iNewStart=GetAChunk(iStart, ChrB(13)&ChrB(10), false, null)
Line = ByteToStr(subString(iStart,iNewStart-2-iStart))
iStart=iNewStart
'空行,则跳出循环
if Line=null or Line="" then Exit do
pos = instr(Line,":")
if pos>0 then
if StrComp(left(Line,pos-1),"Content-Disposition",1)=0 then
'取表单项名称
FieldName = ExtractValue(Line,pos+1,"name")
'取文件名称
FileName = ExtractValue(Line,pos+1,"filename")
'删除文件路径
FileName = Mid(FileName,InStrRev(FileName, "\")+1)
elseif StrComp(left(Line,pos-1),"Content-Type",1)=0 then
'取文件类型
ContentType = trim(mid(Line,pos+1))
end if
end if
loop
ParseHeader = iStart
end function
Private Function GetAChunk(theStart, delimiter, isFile, dest)
iStart = theStart
pos=0
do while pos=0
'长度不够,读一块
if Upload_Stream.Size+1-iStart<lenb(delimiter) then
Upload_Stream.write Request.BinaryRead(65536)
end if
'取一段数据
Upload_Stream.Position = iStart-1
buf = Upload_Stream.Read(-1)
'检测边界
pos=InStrB(buf,delimiter)
'如果未找到,向后移动
if pos=0 then
l = LenB(buf)-LenB(delimiter)+1
else
l = pos-1
end if
if isFile then
Upload_Stream.Position=iStart-1
buf = Upload_Stream.Read(l)
dest.Write buf
buf = Upload_Stream.Read(-1)
Upload_Stream.Position=iStart-1
Upload_Stream.SetEOS
Upload_Stream.Write buf
else
iStart = iStart+l
end if
loop
if isFile then
dest.Position=dest.Size-2
dest.SetEOS
end if
GetAChunk = iStart+LenB(delimiter)
End function
private function ExtractValue(line,pos,name)
dim t, p
ExtractValue = ""
t = name + "="""
p = instr(pos,line,t)
if p>0 then
n1 = p+len(t)
n2 = instr(n1,line,"""")
if n2>n1 then ExtractValue = mid(line,n1,n2-n1)
end if
end function
Private Function subString(theStart,theLen)
if theLen>0 then
Upload_Stream.Position=theStart-1
subString = midb(Upload_Stream.Read(theLen),1)
else
subString = ""
end if
End function
Private function ByteToStr(vIn)
dim i,c
ByteToStr=""
for i=1 to LenB(vIn)
c=ascB(midB(vIn,i,1))
If c > 127 Then
if i=LenB(vIn) then Exit For
ByteToStr = ByteToStr & Chr(AscW(ChrB(AscB(midB(vIn,i+1,1)))&ChrB(c)))
i=i+1
else
ByteToStr = ByteToStr & Chr(c)
End If
Next
end function
Private Sub Class_Terminate
form.RemoveAll
file.RemoveAll
set form=nothing
set file=nothing
Upload_Stream.close
set Upload_Stream=nothing
End Sub
End Class
Class FileInfo
Private FFileName, FContentType, FFileStart, FFileSize, FStream
property get FileName
FileName = FFileName
end property
property get ContentType
ContentType = FContentType
end property
property get FileSize
FileSize = FFileSize
end property
property get Stream
set Stream = FStream
end property
Public Sub Init(AFileName, AContentType)
FFileName = AFileName
FContentType = AContentType
End Sub
Public function SaveAs(FullPath)
dim dr,ErrorChar,i
dStart = CDbl(Time)
SaveAs=1
if trim(fullpath)="" or right(fullpath,1)="/" then exit function
On Error Resume Next
FStream.SaveToFile FullPath,2
if Err.Number>0 then Response.Write "保存数据出错:" & Err.Description & "<br/>"
SaveAs=0
Response.Write "save time:" & (CDbl(Time)-dStart)*24*60*60 & "<br/>"
end function
Private Sub Class_Initialize
set FStream=CreateObject("Adodb.Stream")
FStream.mode=3
FStream.type=1
FStream.open
end sub
Private Sub Class_Terminate
FStream.Close
set FStream=nothing
end sub
End Class
</SCRIPT>
这是我从某个帖子里找到的
如何能得到另一个表单对象文本区域content的内容呢
dim upload
set upload = new QuickUpload
下面如何写才能得到文本区域content的内容呢