有句语句错,请大家帮我看看
一个叫豆腐的无组件实现上传的类,最后一句运行不过请大家帮我调试
顺便请大家帮我看看上传路径应该在哪改(内空太长,我作两次贴)
---------doufuCls.asp
<%@ LANGUAGE = VBScript.Encode %>
<SCRIPT LANGUAGE=VBScript.Encode RUNAT=Server>
Class doufuUpload
'========================================================='
'========================================================='
Private m_objFiles
Private m_objForm
Private m_filePath
Private m_MaxSize
Private strCopyRight
Public Property Get FilePath()
FilePath=m_filePath
End Property
public Property Let FilePath(strPath)
m_filePAth=strPath
end Property
Public Property Get MaxSize()
MaxSize=m_MaxSize
End Property
public Property Let MaxSize(strMax)
m_MaxSize=strMax
end Property
Public Property Get Forms()
Set Forms = m_objForm
End Property
Public Property Get Form(ItemName)
Set M = m_objForm
for i=0 to M.Count-1
if M.item(i).name=ItemName then
set Form=new clsForm
Form.Name=M.item(i).name
Form.value=M.item(i).value
end if
next
End Property
Public Property Get Files()
Set Files = m_objFiles
End Property
Public Property Get File(ItemName)
Set F = m_objFiles
For i = 0 to F.Count - 1
if F.Item(i).name=ItemName then
Set File = New clsFile
File.Name = F.Item(i).name
File.FileName = F.Item(i).FileName
File.ContentType = F.Item(i).ContentType
File.Blob = F.Item(i).Blob
end if
next
End Property
Private Sub Class_Initialize()
Set m_objFiles = New clsCollection
Set m_objForm = New clsCollection
strCopyRight="http://www.asp888.net"
End Sub
public sub Upload()
ParseRequest
'set copyRightForm=new clsForm
Set copyRightForms = m_objForm
'检查版权
copyRightFind=false
for i=0 to copyRightForms.Count-1
if lCase(trim(copyRightForms.item(i).name))="copyright" then
if lcase(copyRightForms.item(i).value)=strCopyRight then
copyRightFind=true
exit for
end if
end if
next
if copyRightFind=false then
err.raise 2,"版权信息", "对不起,您必须在 上传页面 添加 版权信息"
end if
'版权判断结束,下面来判断是否已经超过最大的Maxsize
set FileMaxSize=m_objFiles
dim intMaxSize
for i=0 to FileMaxSize.count-1
intMaxSize=intMaxSize+lenB(FileMAxSize.item(i).Blob)
next
if m_MaxSize>0 then
'如果小于等于 0 表示不对大小进行限制
'反之,如果大于0,则按照这个大小对 字节进行判断
if intMaxSize>m_MaxSize then
err.raise 2,"文件上传--字节大小错误","对不起,现在的上传字节大小(" & cStr(intMaxSize) & "Bytes) 已经大于系统允许的最大允许字节数(" & cStr(m_MaxSize) & "Bytes)"
end if
end if
response.write "上传的大小"+ cStr(intMaxSize)+"bytes"
end sub
Private Sub ParseRequest()
Dim lngTotalBytes, lngPosBeg, lngPosEnd, lngPosBoundary, lngPosTmp, lngPosFileName
Dim strBRequest, strBBoundary, strBContent
Dim strName, strFileName, strContentType, strValue, strTemp
Dim objFile
'得到 从 浏览器 传送过来的全部数据
lngTotalBytes = Request.TotalBytes
strBRequest = Request.BinaryRead(lngTotalBytes)
'找到第一个二进制 数据
lngPosBeg = 1
lngPosEnd = InStrB(lngPosBeg, strBRequest, UStr2Bstr(Chr(13)))
If lngPosEnd > 0 Then
strBBoundary = MidB(strBRequest, lngPosBeg, lngPosEnd - lngPosBeg)
lngPosBoundary = InStrB(1, strBRequest, strBBoundary)
End If
If strBBoundary = "" Then
lngPosBeg = 1
lngPosEnd = InStrB(lngPosBeg, strBRequest, UStr2BStr("&"))
Do While lngPosBeg < LenB(strBRequest)
strTemp = BStr2UStr(MidB(strBRequest, lngPosBeg, lngPosEnd - lngPosBeg))
lngPosTmp = InStr(1, strTemp, "=")
strName = URLDecode(Left(strTemp, lngPosTmp - 1))
strValue = URLDecode(Right(strTemp, Len(strTemp) - lngPosTmp))
Set objForm = New clsForm
objForm.Name=strName
objForm.Value=strValue
m_objForm.Add strName, objForm
lngPosBeg = lngPosEnd + 1
lngPosEnd = InStrB(lngPosBeg, strBRequest, UStr2BStr("&"))
If lngPosEnd = 0 Then lngPosEnd = LenB(strBRequest) + 1
Loop
Else
Do Until (lngPosBoundary = InStrB(strBRequest, strBBoundary & UStr2Bstr("--")))
lngPosTmp = InStrB(lngPosBoundary, strBRequest, UStr2BStr("Content-Disposition"))
lngPosTmp = InStrB(lngPosTmp, strBRequest, UStr2BStr("name="))
lngPosBeg = lngPosTmp + 6
lngPosEnd = InStrB(lngPosBeg, strBRequest, UStr2BStr(Chr(34)))
strName = BStr2UStr(MidB(strBRequest, lngPosBeg, lngPosEnd - lngPosBeg))
lngPosFileName = InStrB(lngPosBoundary, strBRequest, UStr2BStr("filename="))
If lngPosFileName <> 0 And lngPosFileName < InStrB(lngPosEnd, strBRequest, strBBoundary) Then 'It is a file
lngPosBeg = lngPosFileName + 10
lngPosEnd = InStrB(lngPosBeg, strBRequest, UStr2BStr(chr(34)))
strFileName = BStr2UStr(MidB(strBRequest, lngPosBeg, lngPosEnd - lngPosBeg))
lngPosTmp = InStrB(lngPosEnd, strBRequest, UStr2BStr("Content-Type:"))
lngPosBeg = lngPosTmp + 14
lngPosEnd = InstrB(lngPosBeg, strBRequest, UStr2BStr(chr(13)))
strContentType = BStr2UStr(MidB(strBRequest, lngPosBeg, lngPosEnd - lngPosBeg))
lngPosBeg = lngPosEnd + 4
lngPosEnd = InStrB(lngPosBeg, strBRequest, strBBoundary) - 2
strBContent = MidB(strBRequest, lngPosBeg, lngPosEnd - lngPosBeg)
If strFileName <> "" And strBContent <> "" Then
Set objFile = New clsFile
objFile.Name = strName
objFile.FileName = Right(strFileName, Len(strFileName) - InStrRev(strFileName, "\"))
objFile.ContentType = strContentType
objFile.Blob = strBContent
m_objFiles.Add strName, objFile
End If
Else
lngPosTmp = InStrB(lngPosTmp, strBRequest, UStr2BStr(chr(13)))
lngPosBeg = lngPosTmp + 4
lngPosEnd = InStrB(lngPosBeg, strBRequest, strBBoundary) - 2
strValue=MidB(strBRequest, lngPosBeg, lngPosEnd - lngPosBeg)
strValue=BStr2UStr(strValue)
'strValue1= BStr2UStr(MidB(strBRequest, lngPosBeg, lngPosEnd - lngPosBeg))
'response.write "sadmasd" & strValue
'response.end
Set objForm = New clsForm
objForm.Name=strName
objForm.Value=strValue
m_objForm.Add strName, objForm
End If
lngPosBoundary = InStrB(lngPosBoundary + LenB(strBBoundary), strBRequest, strBBoundary)
Loop
End If
End Sub