日期:2011-02-22  浏览次数:20789 次

<!--#include file="../lib/filelib.asp"-->
<%
    Response.write "<title>上传文件至当前文件夹</title>"
    Response.Write "<body bgcolor=""#D6D3CE"" leftmargin=""0"" topmargin=""0"" title = ""    请您遵守国家相关法律法规上传文件。上传前请杀毒,否则系统将会自动删除此文件!"">"

'**Start Encode**
Action=Request("A")
If Action="UL" Then
        DoUpload Request.Cookies("DAZHOU.NET")("nowpath") & "\"
        'CheckDiskSpace
'        Response.redirect "fileman.asp"
Else
    ShowUploadForm
End If

Set fso=Nothing
'========================
SUB ShowUploadForm
'========================
    Response.write "<Dir><form enctype=multipart/form-data name=fmupload method=Post action=Upload.asp?A=UL><br>"
    If Request("n")<>"" AND IsNumeric(Request("n")) Then Session("NumUploadFields")=CInt(Request("n"))
    For i=1 to 5
        Response.Write "<INPUT type=file name=file"& i & " size=35><br>"
    Next
    Response.Write "<br><center><INPUT type=submit value=""开始上传"">  <INPUT type='button' value= '取消上传' > "
    Response.Write "</form>"
End SUB

'========================
SUB DoUpload(Dir)
'========================
    'If NOT Application("Debugging") Then On Error resume next
    StartTime=Now
    RequestBin=Request.BinaryRead(Request.TotalBytes)
    Set UploadRequest=CreateObject("Scripting.Dictionary")
    BuildUploadRequest RequestBin, UploadRequest
    keys=UploadRequest.Keys
    For i=0 to UploadRequest.Count - 1
        curKey=keys(i)
        fName=UploadRequest.Item(curKey).Item("FileName")

        If fso.FileExists(Dir & fName) Then fso.deletefile Dir & fName
        If fName<>"" AND NOT fso.FileExists(Dir & fName) Then
            value=UploadRequest.Item(curKey).Item("Value")
            valueBeg=UploadRequest.Item(curKey).Item("ValueBeg")
            valueLen=UploadRequest.Item(curKey).Item("ValueLen")
            TotalULSize=TotalULSize + valueLen
            Set strm1=Server.CreateObject("ADODB.Stream")
            Set strm2=Server.CreateObject("ADODB.Stream")
            strm1.Open
            strm1.Type=1 'Binary
            strm2.Open
            strm2.Type=1 'Binary
            strm1.Write RequestBin
            strm1.Position=ValueBeg
            strm1.CopyTo strm2,ValueLen