Do not use components to implement multiple pictures and text data to the database at the same time (1)

Source: Internet
Author: User
Tags implement
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



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.