Extract the code description of the uploaded secondary data through the form upload request.totalbytes as a binary file.
Copy the code code as follows:
<input 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 bytes uploaded
-----------------------
formdata=request.binaryread(formsize)
Get form data from binary stream
-----------------------
bncrlf=chrB(13) & chrB(10)
Set crlf carriage return and line feed code variable
----------------------------------
divider=leftB(formdata,clng(instrb(formdata,bncrlf))-1)
Get the byte data to the left of the first crlf
instrb(formdata,bncrlf)-1 The machine checks that the bit value of the crlf binary byte is minus one, which is the binary data before the flag information. It should be noted that instrb returns clng, so a clng is added here. redundant
----------------------------------
datastart=instrb(formdata,bncrlf & bncrlf)+4
Obtain the image data and remove the starting position of the header information added by the form form, which is the byte starting position of the real file data after your type=file is submitted in the form.
The position of two consecutive crlfs + 4 (that is, the length of two crlfg)
----------------------------------
dataend=instrb(datastart+1,formdata,divider)-datastart
The data position + 1 obtained from the above is used as a reference calculation value to check the end of the data. The position of the first binary form delimiter header information is returned at the position starting from datastart + 1, and then the relative position of datastar is subtracted.
----------------------------
mydata=midb(formdata,datastart,dataend)
midb() takes the star end bit format of the uploaded file data obtained through many twists and turns.
ok --------------> Now cleanly extract the uploaded secondary data
Note:
(1). All *B series VB functions are processed by bytes. They must be used to process secondary systems.
(2) After .type=file and the corresponding form type form data are submitted, 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 the data of the uploaded initial file name, such as c:/aaa/aaa.jpg. The formdata data can be processed in the same way to extract the preliminary file name of the file domain data.
(4). These algorithms are derived from the format data provided by the http "form" specification, so the processing algorithms of any company are similar!