Upload | no component <%
' Decide whether to add a 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
FileName = ""
Set Upload = New upload_yfly ' Build upload Object
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
douploadfile= 4 ' No File uploaded
Else
' Upload file is not empty when processing upload
' Add (/) in the catalogue
Formpath=upload. Form ("Ulsavefilepath")
If Right (Formpath, 1) <> "/" Then
Formpath = Formpath & "/"
End If
If File.filesize < Then
douploadfile= 1 ' file size is too small
Exit Function
End If
If file.filesize > Maxuploadsize Then
Douploadfile= 2 ' file size exceeds the limit
Exit Function
End If
Fileext = LCase (Right (File.filename, 4))
UPLOADSUC = False
If Not (Fileext = ". gif" Or fileext = ". jpg") Then
Douploadfile= 3 ' file format is incorrect
Exit Function
End If
Randomize
Rannum = Int (90000 * Rnd) + 10000
' filename
FileName = Formpath & year [now] & Month (now) & Day (now) & Hour (now) & Minute (now) & Second (now) &A mp Rannum & Fileext
If file.filesize > 0 Then ' If FileSize > 0 indicates 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
%>
<script runat= "SERVER" language= "VBSCRIPT" >
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 (&CHR) (10)
Idivlen=instring (1,vbenter) +1
Strdiv=substring (1,idivlen)
Iformstart=idivlen
Iformend=instring (Iformstart,strdiv)-1
While Iformstart < Iformend
Istart=instring (Iformstart, "name=" "")
Iend=instring (Istart+6, "" "")
Mformname=substring (istart+6,iend-istart-6)
Ifilenamestart=instring (iend+1, "filename=" "")
If Ifilenamestart>0 and Ifilenamestart<iformend then
Ifilenameend=instring (ifilenamestart+10, "" "")
Mfilename=substring (IFILENAMESTART+10,IFILENAMEEND-IFILENAMESTART-10)
Istart=instring (Ifilenameend+1,vbenter&vbenter)
Iend=instring (Istart+4,vbenter&strdiv)
If Iend>istart Then
Mfilesize=iend-istart-4
Else
Mfilesize=0
End If
Set Thefile=new FileInfo
Thefile.filename=getfilename (Mfilename)
Thefile.filepath=getfilepath (Mfilename)
Thefile.filesize=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
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&