Data | database ' Filename:upload.inc
'---------------------------------------------------------------------------
------------------------------------------
<script Runat=server language=vbscript>
Function Getupload (FormData)
Dim Datastart,divstr,divlen,datasize,formfielddata
' Delimited sign string (+CRLF)
Divstr = LeftB (FORMDATA,INSTRB (Formdata,str2bin (VbCrLf)) + 1)
' Separating the length of the sign string
Divlen = LenB (DIVSTR)
Posopenboundary = InStrB (FORMDATA,DIVSTR)
Poscloseboundary = InStrB (posopenboundary + 1,formdata,divstr)
Set Fields = CreateObject ("Scripting.Dictionary")
While Posopenboundary > 0 and poscloseboundary > 0
' Name start position (name= "xxxxx"), plus 6 because [name=] length is 6
Fieldnamestart = InStrB (Posopenboundary,formdata,str2bin ("name=")) +
6
Fieldnamesize = InStrB (FIELDNAMESTART,FORMDATA,CHRB (34))-
ASC value for Fieldnamestart ' (") =34
Formfieldname = Bin2str (MidB (formdata,fieldnamestart,fieldnamesize))
' FileName starting position (filename= "xxxxx")
Fieldfilenamestart =
InStrB (Posopenboundary,formdata,str2bin ("filename=")) + 10
If Fieldfilenamestart < poscloseboundary and Fieldfilenamestart >
Posopenboundary Then
Fieldfilenamesize = InStrB (FIELDFILENAMESTART,FORMDATA,CHRB (34))-
ASC value for Fieldfilenamestart ' (") =34
Formfilename =
Bin2str (MidB (formdata,fieldfilenamestart,fieldfilenamesize))
Else
Formfilename = ""
End If
' Content-type starting position (CONTENT-TYPE:XXXXX)
Fieldfilectstart =
InStrB (Posopenboundary,formdata,str2bin ("Content-type:")) + 14
If Fieldfilectstart < poscloseboundary and Fieldfilectstart >
Posopenboundary Then
Fieldfilectsize = InStrB (Fieldfilectstart,formdata,str2bin (VbCrLf
& VbCrLf))-Fieldfilectstart
Formfilect =
Bin2str (MidB (formdata,fieldfilectstart,fieldfilectsize))
Else
Formfilect = ""
End If
' Data start position: 2 CRLF Start
Datastart = InStrB (Posopenboundary,formdata,str2bin (VbCrLf & VbCrLf))
+ 4
If formfilename <> "" Then
' Data length, minus 1 because of the number of bytes accessed by the data file (possibly the AppendChunk method.
Question):
' Because an odd number of bytes of an image is saved to the database, the last character is removed, causing the image to not
Correctly displayed,
' A data file with an even number of bytes does not have this problem, so you must keep the number of bytes as a couple
Number.
DataSize = InStrB (datastart,formdata,divstr)-DataStart-1
Formfielddata = MidB (formdata,datastart,datasize)
Else
' Data length, minus 2 because there is a CRLF in front of the separator flag string
DataSize = InStrB (datastart,formdata,divstr)-DataStart-2
Formfielddata = Bin2str (MidB (formdata,datastart,datasize))
End If
' Create a dictionary set to store the relevant data for each field in the form
Set Field = Createuploadfield ()
Field.name = Formfieldname
Field.filepath = Formfilename