Pure ASP separates binary files and text data from form data

Source: Internet
Author: User
The following source code is a file
<%
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Author: playxp,email:playxp@sohu.com have questions please contact me
' function: Pure ASP separates binary files and text data in form data (supporting Chinese).
' How to: Include this file in the ASP file that processes the form, using GetValue (name) to read the values of each element in the form.
' NOTE: You must not use Request.Form to read data.
' In a large number of support ASP's home page space can only use limited components, can not use the upload component, and the built-in request object is not
' Supports reading binary files, so using this file can solve the problem of uploading files, but it is a significant performance compromise. This program refers to some of the online code.
' Convert from GBK to Unicode
Function Gbtou (Binstr,bytenum)
Gbtou= ""
For J=1 to Bytenum
GBCODE1=ASCB (MidB (binstr,j,1))
If gbcode1>&h80 Then
GBCODE2=ASCB (MidB (binstr,j+1,1))
a=gbcode1-&h81
B=gbcode2-&h40
If gbcode2>&h7f Then b=b-1
Gbtou=gbtou & ChrW (gb2u (a*190+b)) ' Gb2u for conversion tables
J=j+1
Else
Gbtou=gbtou & ChrW (AscB (MidB (binstr,j,1))
End If
Next
End Function
' Get the boundary string
Boundary=mid (Request.ServerVariables ("Content_Type"), 31)
' Number of bytes of data in form
Bytecount=request.totalbytes
' Binary data in form
Binread=request.binaryread (ByteCount)
' Border ASCII string
ENDSTR=CHRB (&AMP;CHRB) &AMP;CHRB &AMP;CHRB (45)
For I=1 to Len (boundary)
ENDSTR=ENDSTR&AMP;CHRB (AscB) (Mid (boundary,i,1))
Next
Dim Formvalue (31,3)
Dim Bytei ' byte pointer
E=0
Bytei=37+len (boundary) ' first element data at the beginning
Do While Bytei<bytecount
If AscB (MidB (binread,bytei,1)) =110 Then ' element data exists
Formvalue (e,0) = ""
Formvalue (e,1) = ""
Formvalue (e,2) = ""
Formvalue (e,3) = ""
Bytei=bytei+6 ' name begins at
Namestart=bytei
BYTEI=INSTRB (BYTEI,BINREAD,CHRB (34)) ' At the end of the name
Related Article

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.