Through the form as a binary file upload request.totalbytes extract the upload of the two-level data-application techniques

Source: Internet
Author: User
Copy Code code as follows:

<input name= "File" type= "file" >
Formsize=request.totalbytes
Formdata=request.binaryread (Formsize)
BNCRLF=CHRB (+) & ChrB (10)
Divider=leftb (FORMDATA,CLNG (INSTRB (FORMDATA,BNCRLF))-1)
DATASTART=INSTRB (Formdata,bncrlf & Bncrlf) +4
DATAEND=INSTRB (Datastart+1,formdata,divider)-datastart
MYDATA=MIDB (Formdata,datastart,dataend)

Formsize=request.totalbytes
Gets the maximum number of bytes uploaded
-----------------------
Formdata=request.binaryread (Formsize)
Get form form data for binary streams
-----------------------
BNCRLF=CHRB (+) & ChrB (10)
Set CRLF carriage return line code variable
------------------------------
Divider=leftb (FORMDATA,CLNG (INSTRB (FORMDATA,BNCRLF))-1)
Gets the byte data to the left of the first CRLF
INSTRB (FORMDATA,BNCRLF)-1 Machine Check out CRLF binary byte of the bit value minus one, that is, the sign bit information before the binary data, it needs to be explained that INSTRB return is clng, so add a clng is redundant
------------------------------
DATASTART=INSTRB (Formdata,bncrlf & Bncrlf) +4
Get the image data, remove the starting position of the header information added to form forms, which is the byte start position of your type=file real file data after form submission
Two consecutive CRLF positions +4 (that is, the length of a CRLFG)
-------------------------------
DATAEND=INSTRB (Datastart+1,formdata,divider)-datastart
From the obtained data position +1 as a reference value for checking the end of the data, the position at the beginning of the datastart+1 to return the first binary form separator header information, minus the relative position of DataStar
----------------------------
MYDATA=MIDB (Formdata,datastart,dataend)
MidB () The star end-bit data of the uploaded file data obtained by the above many setbacks
OK--------------> Now clean to extract the uploaded two-level data

Note:
(1). The VB functions of all *B series are processed by byte byte and the level two system must use them
(2) The Type=file and the corresponding form type forms data are submitted with corresponding header information attached to each file field
So the above algorithm must be used to identify the real file data.
(3). At the same time the header information also contains the upload of the initial file name of the data such as c:\aaa\aaa.jpg, you can also process formdata data and extract the file field data of the first preliminary file name
(4). These algorithms are derived from the format data provided by the HTTP "form" specification, so any one of the algorithms is similar!

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.