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!