The code copy is as follows:
<input name="file" type="file">
formsize=request.totalbytes
formdata=request.binaryread(formsize)
bncrlf=chrB(13) & 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
Get the maximum number of uploaded bytes
--------------------------------------------------------------------------------------------------------------------------------
formdata=request.binaryread(formsize)
Get form form data of binary stream
--------------------------------------------------------------------------------------------------------------------------------
bncrlf=chrB(13) & chrB(10)
Set crlf Enter line break code variable
------------------------------
divider=leftB(formdata,clng(instrb(formdata,bncrlf))-1)
Get the byte data on the left of the first crlf
instrb(formdata,bncrlf)-1 machine checks that the bit value of the binary byte of crlf is reduced by one, that is, the binary data before the flag bit information. It should be noted that instrb returns clng, so adding a clng here is unnecessary
------------------------------
datastart=instrb(formdata,bncrlf & bncrlf)+4
Get the image data and remove the start position of the header information added by the form form, that is, the start position of the bytes of the real file data after the form is submitted by your type=file
The position of two consecutive crlfs +4 (ie, the length of one crlfg)
-------------------------------
dataend=instrb(datastart+1,formdata,divider)-datastart
The data position +1 obtained from the above is used as the reference calculated value for checking the end of the data. The position detection starts at datastart+1 returns the position of the first binary form separator header information, and then subtracts the relative position of the datastar
--------------------------------
mydata=midb(formdata,datastart,dataend)
midb() takes the star end bit data of the upload file data obtained by the above many twists and turns
OK ---------------> Now cleanly extract the uploaded secondary data
Note:
(1). All VB functions of *B series are processed by bytes, and they must be used to handle secondary systems.
(2) After the form data of type=file and corresponding form type are submitted, the corresponding header information is attached to each file field.
Therefore, the above algorithm must be used to clearly find the real file data
(3). At the same time, the header information also contains data uploading the initial file name, such as c:/aaa/aaa.jpg. The data of formdata can be processed the first test file name of the file domain data of the segment.
(4). These algorithms are derived from the format data provided by the http "form" specification, so any processing algorithm is similar!