About ASP no component file uploader

xiaoxiao2021-03-06  41

Often some netizens need to do file upload procedures when doing ASP programs, using the most of the unblened upload assemblies of Daoxiang old agriculture. However, in August this year, Rising actually reported that he is a virus, even if the server is not very sleeple, then I will do one.

After studying the non-component uploading components of Daoxiang Old Nong, I first used an AdoDb.Stream component, after carefully studying this class, I used a few code to implement one, the core code is as follows:

'Establish an AdoDb.Stream object to get the data from POST. set ReadData = Server.CreateObject ( "adodb.stream") ReadData.Type = 1ReadData.Mode = 3ReadData.OpenReadData.Write Request.BinaryRead (Request.TotalBytes) ReadData.Position = 0 'to move in AllData AllData = ReadData.Read

The useful data is extracted according to HTTP POST format, and DataStart is the start position DATAEND as the end position Bncrlf = chrb (13) & chrb (10) Divider = Leftb (AllData, ClNG (INSTRB (AllData, BnCrlf)) - 1) Datastart = INSTRB AllData, Bncrlf & Bncrlf) 4DataEnd = INSTRB (Datastart 1, Alldata, Divider) - DataStart

'Create output data stream to extract the formal go into OutData Set OutData = Server.CreateObject OutData.Type = 1OutData.OpenReadData.Position = datastart-1ReadData.CopyTo OutData ( "ADODB.Stream"), dataend-2' to establish FInfoData extract stream file set FInfoData = Server.CreateObject ( "ADODB.Stream") FInfoData.Type = 1FInfoData.Mode = 3FInfoData.OpenReadData.Position = 0ReadData.CopyTo FInfoData, datastart-1ReadData.Closeset ReadData = Nothing 'gb2312 encoding a discharge the StrInfoFInfoData.Position = 0FInfoData.Type = 2FInfoData.Charset = "gb2312" StrFInfo = FInfoData.ReadTextFInfoData.Closeset FInfoData = Nothing 'takes the file name Nstart = Instr (1, StrFInfo, "filename =" "", 1) 10Nend = INSTAR (NStart, Strfinfo, "" "", 1) filename = MID (Strfinfo, NStart, Nend-NStart)

Filename = getFileName (filename) extname = getExtName (filename)

'Save Outdata.Savetofile Server.mappath (IDMaker & ", 2, 2

Outdata.closset Outdata = Nothing

Original code download

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

New Post(0)