<%
'When the form contains both text fields and file fields, we must set the form encoding type to the multipart/form-data type.
'At this time, the uploaded encoding file cannot directly retrieve the value of the text field and the binary data of the file field. This requires splitting the form field.
'There is a random separator between each form field in the uploaded data stream. This separator remains unchanged in the same stream, and different stream delimiters remain unchanged,
'The separator starts at the beginning of the stream and ends with a chrb (13) + chrb (10). After knowing this, we can use this separator to traverse the split form field.
'For the file domain, we want to resolve the field name, file name, file type and file content. The domain name is prefixed with "name =" and is contained in a pair of double quotation marks, the file name value is prefixed with "filename =" and is also contained in double quotation marks. It contains the full path and file name of the file, followed by a pair of carriage return lines (chrb (13) + chrb (10), the content between the string "content-type:" and the two carriage return headers is a file-type string, the data between the two carriage return and the one to the other is the file content.
'The text field only needs to be parsed. The field name is enclosed in double quotation marks after "name =, the value of this text field is between two line breaks and the domain separator starting with a line break.
'Of course, the uploaded stream is in binary format. During the operation, you need to use some binary functions instead of string functions, such as leftB, midB, and limit B, the following figure shows the algorithm implementation.
Class GetPost
Private BdataStr, SeparationStr, wawa_stream 'submitted information, separated by form fields
'Class initialization
Private Sub Class_Initialize
Set wawa_stream = CreateObject ("Adodb. Stream") 'to create a global Stream
Wawa_stream.mode = 3' read/write mode
Wawa_stream.type = 1' binary read mode
Wawa_stream.open 'open the stream
BdataStr = Request. BinaryRead (Request. TotalBytes) 'Get all uploaded data
Wawa_stream.write BdataStr 'reads data
SeparationStr = LeftB (BdataStr, Clng (limit B (BdataStr, ChrB (13) + ChrB (10)-1) 'separator string
End Sub
'Class destructor, unload the global stream object
Private Sub Class_Terminate
Wawa_stream.close
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.