ploadSizeLimit 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" 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
'********************************** SeparateFields ********************************** 'This function retrieves the upload fields from binary data and retuns the fields as array 'Binary is safearray of all raw binary data from input. Function SeparateFields(Binary, Boundary) Dim PosOpenBoundary, PosCloseBoundary, PosEndOfHeader, isLastBoundary Dim Fields Boundary = StringToBinary(Boundary)
PosOpenBoundary = InstrB(Binary, Boundary) PosCloseBoundary = InstrB(PosOpenBoundary + LenB(Boundary), Binary, Boundary, 0)
Set Fields = CreateObject("Scripting.Dictionary")
Do While (PosOpenBoundary > 0 And PosCloseBoundary > 0 And Not isLastBoundary) 'Header and file/source field data Dim HeaderContent, FieldContent 'H 上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] 下一页 |