ASP implements code uploaded without component files

xiaoxiao2021-03-06  57

Note that you need to add Properties encType = "multipart / form-data" in Form

In fact, you can test data like this.

Datalen = Request.Totalbytes

Formdata = Request.binaryRead (Datalen)

Response.binaryWrite Formdata

I know the format of the data.

<%

Function str2bin (Varstr)

Str2bin = ""

For i = 1 to Len (Varstr)

VARCHAR = MID (Varstr, I, 1)

Varasc = ASC (varchar)

'ASC's value for Chinese characters may be negative,

'Plus 65536 can find its unsigned value

'-1 is 0xFFFF represented by complement in the machine.

'The no symbol value is 65535, 65535 = -1 65536

'The other negative numbers are pushed.

IF Varasc <0 THEN

Varasc = Varasc 65535

END IF

'Treatment to Chinese: Separate double bytes low and high

IF Varasc> 255 THEN

Varlow = Left (HEX (ASC (VARCHAR)), 2)

Varhigh = Right (HEX (ASC (varchar)), 2)

Str2bin = str2bin & chrb ("& H" & varlow) & chrb ("& H" & varhigh)

Else

Str2bin = str2bin & chrb (ASCB (varchar))

END IF

NEXT

END FUNCTION

Function Bin2Str (Binstr)

DIM VARLEN, CLOW, CCC, Skipflag

'Chinese character SKIP logo

Skipflag = 0

CCC = ""

IF not isnull (binstr) THEN

Varlen = lenb (binstr)

For i = 1 to varlen

IF Skipflag = 0 THEN

Clow = MIDB (Binstr, I, 1)

'Judging whether it is Chinese characters

IF ASCB (CLOW)> 127 THEN

'ASCW will reverse the binary Chinese double-byte character with high position and low position, so the high and low level of Chinese will be reversed.

CCC = CCC & CHR (ASCW (MIDB (Binstr, I 1, 1) & Clow)

Skipflag = 1

Else

CCC = CCC & CHR (ASCB (CLOW))

END IF

Else

Skipflag = 0

END IF

NEXT

END IF

Bin2Str = CCC

END FUNCTION

%>

<%

Datalen = Request.TotalBytes' Getting Data Size

Formdata = Request.binaryRead (DATALEN) 'Read the original data

StrformData = bin2str (Formdata)

Divstr = Leftb (Formdata, INSTRB (FormData, Str2bin (VBCRLF)) - 1) 'This is the separator of the data,

Randomly generated, you can test yourself

Divlen = lenb (divstr)

LNGFILENAMESTART = INSTR (StrformData, "FileName =" & chr (34)) LEN ("FileName =" & chr (34))

LNGFILENAMEEND = INSTR (LNGFileNamestart, StrformData, CHR (34))

Strfilename = MID (StrformData, LngfileNamestart, LngFileNameEnd-LngFileNameStart)

Strfilename = trim (strfilename)

Strfilename = Replace (strfilename, vbcrlf, vbnullstring) 'gets the file name

Set objstream = Server.createObject ("adodb.stream")

Set objstream1 = server.createObject ("adodb.stream")

Objstream.Type = 1

Objstream1.type = 1

Objstream.mode = 3

Objstream1.mode = 3

Objstream.open 'Formdata

Objstream1.open

'ObjStream.Type = 1' adtypebinary

Objstream.write Formdata

Objstream.position = datastart-1

Objstream.couthto objstream1, DataSize

Objstream1.savetofile server.mappath ("Image /" & filename)

Objstream.close

Objstream1.close

%>

转载请注明原文地址:https://www.9cbs.com/read-109085.html

New Post(0)