<% 'Judging whether the file DIM ULFILENAME, ULRESULT
Ulsavetopath = "/ upload" 'Save File Path ULMAXFILESIZE = 1000000' File Size limit 1000,000
UlResult = douploadFile (ulmaxfilesize, ulfilename)
Function DouploadFile (MAXUPLOADSIZE, FILENAME) DIM UPLOAD, FILE, FORMNAME, FORMPATH, FILEEXT FORMNAME = "" 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 = "" THEN DOUPLOADED ELSE 'Upload file is not empty to process upload' after the directory (/) FormPath = UPLOAD.FORM ("UlsaveFilePath") IF Right (FormPath, 1) <> "/" THEN FORMPATH = FormPath & "/" end if fix.filesize <100 Then DouploadFile = 1 'file size too small exit function end if fix.filesize> maxUploadsize the douploadfile = 2' file size exceeded EXIT function end if fixedext = LCase (Right (file.filename, 4)) UPLOADSUC = false if not (fileext = ".gif" OR fileext = ".jpg") The dolploadFile = 3 'file format incorrect EXIT FUNCTION END I fly
Randomize Rannum = INT (90000 * RND) 10000 'File Name FileName = FormPath & Year (NOW) & Month (Now) & Second (NOW) & SECOND (NOW) & 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
mFileSize theFile.FileStart = iStart 4 theFile.FormName = 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 wendEnd SubPrivate 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 (ASCW (Ascb (Upfile_YFLY_STREAM.READ (1))) & chrb (c))) i = i 1 else stemp = STEMP & ChR (c) end if next subsistring = STEMPEND FUNCTION
Private Function inString (theStart, 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 theLen if upfile_yfly_Stream.EOS then inString = 0 Exit for end IF if ASCB (Upfile_YFLY_STREAM.READ (1)) <> ASCB (MIDB (Str, J, 1)) THEN Instring = 0 exit for end if Next if instribrative <> 0 THEN EXIT FUNCTION END IF NEXTEND 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 = nothing end ifEnd Sub Private function GetFilePath (FullPath) If FullPath <> "" Then GetFilePath = left (FullPath, InStrRev (FullPath, "/")) Else GetFilePath = "" End If End function Private function GetFileName (FullPath) If FullPath <> " "THEN getFileName = MID (Fullpath, INSTRRRRRRRRRRRRRRRRRRRRRE (Fullpath," / ") 1) Else getFileName =" "END if End functionPrivate function Tobyte (STR) DIM I, ICODE, C, ILOW, IHIGH TOBYTE =" "for i = 1 to Len (STR) C = MID (STR, I, 1) ICODE = ASC (C) if iF icide <0 Then iCode = iCode 65535 if iF icode> 255 Then iLow = Left (HEX (ASC (C)), 2 ) Ihigh = Right (HEX (ASC (C)), 2) Tobyte = Tobyte & Chrb ("& H" & ilow) & chrb ("& H" & ihigh) Else Tobyte = Tobyte & Chrb (ASCB (c)) end if next end Functionend Class