function | upload | no components | Chinese: No component File upload ASP function, because ASP does not support binary write file, so the file must use components, this function only provides interception of uploaded file data, you can write to the database.
<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)-Fieldnamestart ' (") the ASC value =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)-Fieldfilenamestart ' (") the ASC value =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 (may be a problem with the AppendChunk method):
' Because an odd number of bytes of an image is saved to the database, the last character is removed, causing the image to display incorrectly.
This problem does not occur with a data file with an even number of bytes, so you must keep the number of bytes even.
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
Field.filename = GetFileName (formfilename)
Field.contenttype = Formfilect