<% 'Determines whether to add a file Dim ulFileName, ulResult ulSaveToPath = "/ upload"' Save File Path ulMaxFileSize = 1000000 'file size limit of 1000,000 ulResult = DoUploadFile (ulMaxFileSize, ulFileName) Function DoUploadFile (MaxUpLoadSize, FileName) Dim Upload, File, formName, formPath, FileExt FileName = "" Set Upload = New upload_yfly 'established upload objects IF IsNull (Upload.File) THEN DoUploadFile = 6 EXIT Function END IF IF Upload.File.Count = 0 Then DoUploadFile = 5' No File Uploaded else set file = upload.file ("ulfiletoupload") if file.filename = "" "The DouploadFile = 4 'no file uploaded else' Upload file is not empty, handle the upload 'after the directory (/) FormPath = Upload. Form ("UlsaveFilePath") if right (FormPath, 1) <> "/" THEN FORMPATH = FormPath & "End if if file.filesize <100 THEN DOUPLOADFILE = 1 'file size too small exit function end if fix. FileSize> MaxUPloadsize the dolploadFile = 2 'file size exceeds limit function end if fileext = lcase (Right (file.filename, 4)) UPLOADSUC = false if not (fileext = ".gif" OR feed = ".jpg") The douploadfile = 3 'file format is incorrect EXIT FUNCTION End if Random Ize Rannum = int (90000 * RND) 10000 'File Name FileName = FormPath & Year (now) & Month (NOW) & HOUR (NOW) & Minute (NOW) & Second (Now) & Rannum & Rannum & Rannum & FileExt if file.filesize> 0 Then '' If FileSize> 0 Description has file data file.saveas server.mappath (filename) '' save file end if douploadFile = 0 end if set file = Nothing end if set upload = nothing 'Delete This object end function%>
dim upfile_yfly_Stream Class upload_yfly dim Form, File, Version Private Sub Class_Initialize dim iStart, iFileNameStart, iFileNameEnd, iEnd, vbEnter, iFormStart, iFormEnd, theFile dim strDiv, mFormName, mFormValue, mFileName, mFileSize, mFilePath, iDivLen, mStr Version = "" File = NULL Form = Null upfile_yfly_Stream = NULL if Request.TotalBytes <1 then Exit Sub set Form = CreateObject ( "Scripting.Dictionary") set File = CreateObject ( "Scripting.Dictionary") set upfile_yfly_Stream = CreateObject ( "Adodb.Stream") upfile_yfly_Stream.mode = 3 upfile_yfly_Stream.type = 1 upfile_yfly_Stream.open upfile_yfly_Stream.write Request.BinaryRead (Request.TotalBytes) vbEnter = Chr (13) & Chr (10) iDivLen = inString (1, vbEnter) 1 strDiv = subString (1, iDivLen) iFormStart = iDivLen iFormEnd = inString (iformStart, strDiv) -1 while iFormStart
FormName file.add mFormName, theFile else iStart = inString (iEnd 1, vbEnter & vbEnter) iEnd = inString (iStart 4, vbEnter & strDiv) if iEnd> iStart then mFormValue = subString (iStart 4, iEnd-iStart-4) else mFormValue = "" end if form.Add mFormName, mFormValue end if iFormStart = iformEnd iDivLen iFormEnd = inString (iformStart, strDiv) -1 wend End Sub Private Function subString (theStart, theLen) dim i, c, stemp upfile_yfly_Stream.Position = theStart- 1 stemp = "" for i = 1 to theLen if upfile_yfly_Stream.EOS then Exit for c = ascB (upfile_yfly_Stream.Read (1)) If c> 127 Then if upfile_yfly_Stream.EOS then Exit for stemp = stemp & Chr (AscW (ChrB (AscB (UPFILE_YFLY_STREAM.READ (1))) & chrb (c))) i = i 1 else Stemp = STEMP & CHR (c) end if next subside = STEMP END FUNCTION Private Function Instring (Thatstart, Varstr) DIM i, J, BT, theLen, str InString = 0 Str = toByte (varStr) theLen = LenB (Str) for i = theStart to upfile_yfly_Stream.Size-theLen if i> upfile_yfly_Stream.size then exit Function upfile_yfly_Stream.Position = i-1 if AscB (upfile_yfly_Stream.Read (1)) = ASCB (MIDB (STR, 1)) THEN INSTRING = I for j = 2 to theleen if upfile_yfly_stream.eos dam (Upfile_yfly_stream.read (1)) <> ASCB (MIDB (STR, j, 1)) then InString = 0 Exit For end if next if InString <> 0 then Exit Function end if next End Function Private Sub Class_Terminate if not isNull (form) then form.RemoveAll set form = nothing end if if not isNull ( FILE) THEN FILE.Removeall Set File = Nothing End if if not isnull (Upfile_YFLY_STREAM) THEN UPFILE_YFLY_STREAM.CLOSE SET UPFILE_YFLY_STREAM =