Upload function without component (English NT)

Source: Internet
Author: User
Tags chr
'----file name/upaoad.asp/

<%
Public Function builduploadrequest (strrequestbin)
Dim Posbeg, Posend, boundary, Boundarypos
' Get the boundary
Posbeg = 1
Posend = InstrB (posbeg,strrequestbin,getbytestring (Chr (13)))
Boundary = MidB (Strrequestbin,posbeg,posend-posbeg)
Boundarypos = InstrB (1,strrequestbin,boundary)

' Get all data inside the boundaries
Do Until (Boundarypos = InstrB (Strrequestbin,boundary & Getbytestring ("--)")
' members variable of the objects are put in a Dictionary object
Dim Uploadcontrol
Set Uploadcontrol = CreateObject ("Scripting.Dictionary")

Dim Pos, Name
' Get ' object name
Pos = InstrB (boundarypos,strrequestbin,getbytestring ("Content-disposition"))
Pos = InstrB (pos,strrequestbin,getbytestring ("Name="))
Posbeg = Pos + Len ("name=") + 1
Posend = InstrB (posbeg,strrequestbin,getbytestring (Chr (34)))
Name = getString (MidB (Strrequestbin,posbeg,posend-posbeg))

Dim Posfile, Posbound, ContentType, Value
' Test if object is of file type
Posfile = InstrB (boundarypos,strrequestbin,getbytestring ("Filename="))
Posbound = InstrB (posend,strrequestbin,boundary)

If posfile <> 0 and Posfile < Posbound Then
' Get filepathname of the ' file
Posbeg = Posfile + Len ("filename=") + 1
Posend = InstrB (posbeg,strrequestbin,getbytestring (Chr (34)))
Filepathname = getString (MidB (Strrequestbin,posbeg,posend-posbeg))

' ADD filename (with path) to Dictionary object
Uploadcontrol.add "Filepathname", filepathname

' Get Content-type of the ' file
Pos = InstrB (posend,strrequestbin,getbytestring ("Content-type:"))
Posbeg = Pos + Len ("Content-type:") + 1
Posend = InstrB (posbeg,strrequestbin,getbytestring (Chr (13)))
ContentType = getString (MidB (Strrequestbin,posbeg,posend-posbeg))

' Add Content-type to Dictionary object
Uploadcontrol.add "ContentType", ContentType

' Get content of object '
Posbeg = Posend + 4
Posend = InstrB (posbeg,strrequestbin,boundary)-2
Value = MidB (Strrequestbin,posbeg,posend-posbeg)
Else
' Get content of object '
Pos = InstrB (pos,strrequestbin,getbytestring (Chr (13)))
Posbeg = Pos + 4
Posend = InstrB (posbeg,strrequestbin,boundary)-2
Value = getString (MidB (Strrequestbin,posbeg,posend-posbeg))
End If

' Add content to Dictionary object
Uploadcontrol.add "Value", value

' Add Dictionary object to main dictionary
Set uploadrequest (Name) = Uploadcontrol

' Loop to Next object '
Boundarypos = InstrB (Boundarypos+lenb (boundary), strrequestbin,boundary)
Loop
End Function

' String to byte string conversion
Public Function getbytestring (strstring)
Dim intcount

getbytestring = ""

For intcount = 1 to Len (strstring)
getbytestring = getbytestring & ChrB (AscB (Mid (strstring,intcount,1))
Next
End Function

' Byte string to string conversion
Public Function getString (strstring)
Dim intcount

getString = ""

For intcount = 1 to LenB (strstring)
getString = getString & Chr (AscB (MidB (strstring,intcount,1))
Next
End Function
%>



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.