Upload.asp
<%
DIM UPFILE_5XSOFT_STREAM
Class Upload_5xsoft
DIM FORM, FILE, VERSION
Private Sub Class_Initialize dim iStart, iFileNameStart, iFileNameEnd, iEnd, vbEnter, iFormStart, iFormEnd, theFiledim strDiv, mFormName, mFormvalue, mFileName, mFileSize, mFilePath, iDivLen, mStrVersion = "" if Request.TotalBytes <1 then Exit Subset Form = CreateObject ( "Scripting.Dictionary") set File = CreateObject ( "Scripting.Dictionary") set upfile_5xSoft_Stream = CreateObject ( "Adodb.Stream") upfile_5xSoft_Stream.mode = 3upfile_5xSoft_Stream.type = 1upfile_5xSoft_Stream.openupfile_5xSoft_Stream.write Request.BinaryRead (Request.TotalBytes)
vbEnter = Chr (13) & Chr (10) iDivLen = inString (1, vbEnter) 1strDiv = subString (1, iDivLen) iFormStart = iDivLeniFormEnd = inString (iformStart, strDiv) -1while iFormStart
IFORMStart = iformend idivlenifornd = Instring (iformstart, strdiv) -1wendend Sub
Private Function subString (theStart, theLen) dim i, c, stempupfile_5xSoft_Stream.Position = theStart-1stemp = "" for i = 1 to theLenif upfile_5xSoft_Stream.EOS then Exit forc = ascB (upfile_5xSoft_Stream.Read (1)) If c> 127 Thenif upfile_5xSoft_Stream.EOS then Exit forstemp = stemp & Chr (AscW (ChrB (AscB (upfile_5xSoft_Stream.Read (1))) & ChrB (c))) i = i 1elsestemp = stemp & Chr (c) End IfNextsubString = stempEnd functionPrivate Function inString (theStart, varStr ) dim i, j, bt, theLen, strInString = 0Str = toByte (varStr) theLen = LenB (Str) for i = theStart to upfile_5xSoft_Stream.Size-theLenif i> upfile_5xSoft_Stream.size then exit Functionupfile_5xSoft_Stream.Position = i-1if AscB ( upfile_5xSoft_Stream.Read (1)) = AscB (midB (Str, 1)) thenInString = ifor j = 2 to theLenif upfile_5xSoft_Stream.EOS then inString = 0Exit forend ifif AscB (upfile_5xSoft_Stream.Read (1)) <> AscB (MidB (Str , J, 1)) THENINSTRING = 0EXIT Forend ifnextif Instring <> 0 THEN EXIT FUNCTIONEND IFNEXTEND FUNCTION
Private sub coplass_terminate form.removeallfile.removeallset form = NothingSet file = Nothingupfile_5xsoft_stream.closset upfile_5xsoft_stream = Nothingend Sub
Private function getfilepath (Fullpath) if Fullpath <> "" "THENGETFILEPATH = Left (Fullpath, INSTRREV (Fullpath," / ")) ElsegetFilePath =" "end ifend function
Private function getFilename (Fullpath) if Fullpath <> "" "" "" "" ElsegetFileName = "" "=" = "" endpath, instro
Private function Tobyte (STR) DIM I, ICODE, C, ILOW, IHIGHTOBYTE = "" for i = 1 to Len (STR) C = MID (Str, I, 1) ICODE = ASC (C) IF ICODE <0 THEN iCODE = ICODE 65535IF ICODE> 255 TENILOW = Left (HEX (ASC (C)), 2) ihigh = Right (HEX (ASC (C)), 2) Tobyte = Tobyte & Chrb ("& H" & ilow) & chrb (" & H "& iHigh) ElsetoByte = toByte & chrB (AscB (c)) End IfNextEnd functionEnd ClassClass FileInfodim FormName, FileName, FilePath, FileSize, FileStartPrivate Sub Class_Initialize FileName =" "FilePath =" "FileSize = 0FileStart = 0FormName =" "End Sub
Public function SaveAs (FullPath) dim dr, ErrorChar, iSaveAs = 1if trim (fullpath) = "" or FileSize = 0 or FileStart = 0 or FileName = "" then exit functionif FileStart = 0 or right (fullpath, 1) = "/ "then exit functionset dr = CreateObject (" Adodb.Stream ") dr.Mode = 3dr.Type = 1dr.Openupfile_5xSoft_Stream.position = FileStart-1upfile_5xSoft_Stream.copyto dr, FileSizedr.SaveToFile FullPath, 2dr.Closeset dr = nothing SaveAs = 0end functionEnd Class%>
Pre.asp
<% response.buffer = true%>
<% Set upload = new upload_5xsoft
Set file1 = UPLOAD.FILE ("file1") spath1 = "Position Save /"
If File1.Filesize> 0 Then sfilename = "file name" sfilename1 = sfilename & right (file1.filename, 4) file1.saveas server.mappath (spath1 & sfilename1) end if%>
Index.asp