asp代码问题有一行出错帮忙解决,谢谢!

wangwang008 2009-09-18 03:02:45
Function GetUpload()
Dim Result
Set Result = Nothing
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then 'Request method must be "POST"
Dim CT, PosB, Boundary, Length, PosE
CT = Request.ServerVariables("HTTP_Content_Type") 'reads Content-Type header
If LCase(Left(CT, 19)) = "multipart/form-data" Then 'Content-Type header must be "multipart/form-data"
'This is upload request.
'Get the boundary and length from Content-Type header
PosB = InStr(LCase(CT), "boundary=") 'Finds boundary
If PosB > 0 Then Boundary = Mid(CT, PosB + 9) 'Separetes boundary
Length = CLng(Request.ServerVariables("HTTP_Content_Length")) 'Get Content-Length header
if "" & UploadSizeLimit<>"" then
UploadSizeLimit = clng(UploadSizeLimit)
if Length > UploadSizeLimit then
' on error resume next 'Clears the input buffer
' response.AddHeader "Connection", "Close"
' on error goto 0
Request.BinaryRead(Length)
'Err.Raise 2, "GetUpload", "Upload size " & FormatNumber(Length,0) & "B exceeds limit of " & FormatNumber(UploadSizeLimit,0) & "B"
'Err.Raise 6, "GetUpload", "Upload File too Long!"
set GetUpload=nothing
exit function
end if
end if

If Length > 0 And Boundary <> "" Then 'Are there required informations about upload ?
Boundary = "--" & Boundary
Dim Head, Binary
Binary = Request.BinaryRead(Length) 'Reads binary data from client

'Retrieves the upload fields from binary data
Set Result = SeparateFields(Binary, Boundary)
Binary = Empty 'Clear variables
Else
Err.Raise 10, "GetUpload", "Zero length request ."
End If
Else
Err.Raise 11, "GetUpload", "No file sent." '此行出错
End If
Else
Err.Raise 1, "GetUpload", "Bad request method."
End If
Set GetUpload = Result
End Function
...全文
76 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
三楼の郎 2009-09-18
  • 打赏
  • 举报
回复
试试把调用改成这样:
UploadSizeLimit=1000000
on error resume next
Set Fields1 = GetUpload()
if err.number<>0 then
response.write(err.number & " "err.Description )
end if
三楼の郎 2009-09-18
  • 打赏
  • 举报
回复
试试把调用改成这样:
UploadSizeLimit=1000000
on error resume next
Set Fields1 = GetUpload()
if err.number<>0 then
response.write(err.number & " "err.Description )
end if
三楼の郎 2009-09-18
  • 打赏
  • 举报
回复
你SeparateFields这个函数没有贴出来,其它部分代码没有问题,你说有错误是因为你对Err.Raise作用不了解,实际上代码没问题!
loveinet_168 2009-09-18
  • 打赏
  • 举报
回复
少了一个END IF 加一个进去试试看。
bo3235 2009-09-18
  • 打赏
  • 举报
回复
看了半天,没看出来什么,感觉少了个什么标记,好像是END IF
wangwang008 2009-09-18
  • 打赏
  • 举报
回复
是这样调用的。
UploadSizeLimit=1000000
Set Fields1 = GetUpload()

28,406

社区成员

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

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