ASP no component uploaded source code (improved version)

xiaoxiao2021-03-06  33

'On the next pass over directly receive data lngRequestSize and binRequestData are on the page file submitted directly controls over can lngRequestSize = request.totalbytes binRequestData = request.binaryread (lngRequestSize)' session reconnaissance Yuncanchayu unsteady session ( " lngRequestSize ") = lngRequestSize session (" binRequestData ") = binRequestDataSet objStream = Server.CreateObject (" ADODB.Stream ") lngRequestSize = session (" lngRequestSize ") binRequestData = session (" binRequestData ") objStream.Type = 1 objStream.Open objStream .Write binRequestData dim curr: curr = 1 Set formStream = Server.CreateObject ( "ADODB.Stream") Dim bCrLf, strSeparator, intSeparator bCrLf = ChrB (13) & ChrB (10) intSeparator = InstrB (1, binRequestData, bCrLf) -1 STRSEPARATOR = Leftb (binRequestData, INTSEPARATOR) P_Start = INTSEPARATOR 2 p_END = INTSEPARATOR 2

Dim p_start, p_end, intTemp dim looptime looptime = 0 dim headertext, disptext do while p_start 3 0 then p_start = p_end p_end = InStrB (p_start, binRequestData, strSeparator) -1 objStream.Position = p_start formStream. type = 1 formStream.open objStream.CopyTo formStream, p_end - p_start formStream.Position = 0 formStream.Type = 2 formStream.Charset = "SHIFT-JIS" disptext = formStream.ReadText formStream.SaveToFile Pstr_Folder & Pstr_File_Name, 2 b = split ( Dispte xt, vbcrlf) formStream.close else p_start = p_end p_end = InStrB (p_start, binRequestData, strSeparator) -1 end if p_start = p_end intSeparator 2 loop set formStream = nothing objStream.close set objStream = nothing more than the code sometimes The uploaded file will be more than two bytes than the actual file, because it involves the last line to read the problem, but does not affect the correctness of the uploaded file, but you feel more than two bytes, It can be improved to the following code to solve this problem.

Set objStream = Server.CreateObject ( "ADODB.Stream") lngRequestSize = session ( "lngRequestSize") binRequestData = session ( "binRequestData") objStream.Type = 1 objStream.Open objStream.Write binRequestData dim curr: curr = 1 Set formStream = Server.CreateObject ( "ADODB.Stream") Dim bCrLf, strSeparator, intSeparator bCrLf = ChrB (13) & ChrB (10) intSeparator = InstrB (1, binRequestData, bCrLf) -1strSeparator = LeftB (binRequestData, intSeparator) p_start = intSeparator 2 p_end = INTSEPARATOR 2

P1_start = INTSEPARATOR 2 P1_END = INTSEPARATOR 2

looptime = 0 do while p1_start 3

dim headertext, disptext, totaltext TempLoopTime = 0 do while p_start 3

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

New Post(0)