电信主站 网通分站
购买流程 付款方式 常见问题 在线提问 续租服务 购物车
用户名: 密 码: 忘记密码?
首 页
域名注册
虚拟主机
双线主机
服务器租用
VPS主机
企业邮局
代理专区
客服中心
虚拟主机行业资讯 虚拟主机评测对比 互联网最新动态 技术学院 站长资讯 在线教程 网站运营
搜索优化 服务器 网络编程 图形图象 站长之家 网页制作 操作系统
冲浪宝典 软件教学 视频通信 办公软件 邮件系统 网络安全 认证考试
您当前位置:西部数码->资讯中心-> 技术学院
一个的无组件上传的ASP代码
作者:未知 点击:60
  西部数码-全国虚拟主机10强!20余项虚拟主机管理功能,全国领先!第6代双线路虚拟主机,南北访问畅通无阻!虚拟主机可在线rar解压,自动数据恢复设置虚拟目录等.虚拟主机免费赠送访问统计,企业邮局.Cn域名注册10元/年,自助建站480元起,免费试用7天,满意再付款!P4主机租用799元/月.月付免压金!
文章页数:[1] 
<!--#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= '取消上传' onclick='window.close()'> "
    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
            strm2.SaveToFile Dir & fName,2
            Set strm1=Nothing
            Set strm2=Nothing
        End If
     Next
    If Now>StartTime Then Response.Write("<br><br><br><br><center>上传成功!<br>速度: " & Round(TotalULSize/1024/DateDiff("s",StartTime,Now)) &" 千字节/秒" )
    Set UploadRequest=Nothing
End SUB

'========================
Sub BuildUploadRequest(RequestBin, UploadRequest)
'========================
    'Get the boundary
    PosBeg=1
    PosEnd=InstrB(PosBeg,RequestBin,getByteString(chr(13)))
    boundary=MidB(RequestBin,PosBeg,PosEnd-PosBeg)
    boundaryPos=InstrB(1,RequestBin,boundary)
    'Get all data inside the boundaries
    Do until (boundaryPos=InstrB(RequestBin,boundary & getByteString("--")))
        'Members variable of objects are put in a dictionary object
        Dim UploadControl
        Set UploadControl=CreateObject("Scripting.Dictionary")
        'Get an object name
        Pos=InstrB(BoundaryPos,RequestBin,getByteString("Content-Disposition"))
        Pos=InstrB(Pos,RequestBin,getByteString("name="))
        PosBeg=Pos+6
        PosEnd=InstrB(PosBeg,RequestBin,getByteString(chr(34)))
        Name=getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
        PosFile=InstrB(BoundaryPos,RequestBin,getByteString("filename="))
        PosBound=InstrB(PosEnd,RequestBin,boundary)
        'Test if object is of file type
        If PosFile<>0 AND (PosFile<PosBound) Then
            'Get Filename, content-type and content of file
            PosBeg=PosFile + 10
            PosEnd=InstrB(PosBeg,RequestBin,getByteString(chr(34)))
            FileName=getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
            FileName=Mid(FileName,InStrRev(FileName,"\")+1)
            'Add filename to dictionary object
            UploadControl.Add "FileName", FileName
            Pos=InstrB(PosEnd,RequestBin,getByteString("Content-Type:"))
            PosBeg=Pos+14
            PosEnd=InstrB(PosBeg,RequestBin,getByteString(chr(13)))
            'Add content-type to dictionary object
            ContentType=getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
            UploadControl.Add "ContentType",ContentType
            'Get content of object
            PosBeg=PosEnd+4
            PosEnd=InstrB(PosBeg,RequestBin,boundary)-2
            Value=FileName
            ValueBeg=PosBeg-1
            ValueLen=PosEnd-Posbeg
        Else
            'Get content of object
            Pos=InstrB(Pos,RequestBin,getByteString(chr(13)))
            PosBeg=Pos+4
            PosEnd=InstrB(PosBeg,RequestBin,boundary)-2
            Value=getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
            ValueBeg=0
            ValueEnd=0
        End If
        UploadControl.Add "Value" , Value
        UploadControl.Add "ValueBeg" , ValueBeg
        UploadControl.Add "ValueLen" , ValueLen
        UploadRequest.Add name, UploadControl
        BoundaryPos=InstrB(BoundaryPos+LenB(boundary),RequestBin,boundary)
    Loop
End Sub

'====================================
Function getByteString(StringStr)
'====================================
    For i=1 to Len(StringStr)
         char=Mid(StringStr,i,1)
        getByteString=getByteString & chrB(AscB(char))
    Next
End Function

'====================================
Function getString(StringBin)
'====================================
    getString =""
    For intCount=1 to LenB(StringBin)
        getString=getString & chr(AscB(MidB(StringBin,intCount,1)))
    Next
End Function
%>


文章整理:西部数码--专业提供域名注册虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!
相关主题
文章页数:[1] 
Google
热门文章
·MDAC2.8 下载!
·MySQL和SQLServer,到底选择谁?
·卖虚拟主机常见骗术
·国际域名知识信息注册全解
·让你的网站快速列入Google的最佳方法
·人站长应了解的最基础的知识
·PHP 和 MySQL 基础教程
·网站常用工具网站
·常用域名管理后台
·巧用百度BAIDU搜索电影

最新文章
·国内中文搜索实用攻略
·巧用百度BAIDU搜索电影
·网站排名:咱也权威一把
·专用小型搜索引擎
·搜出网上精彩
·实用网络搜索技巧
·用户搜索常见问题及解决方法小结
·如何查看自定义天数的ALEXA数据
·Alexa.com的排名原理
·内幕调查:出卖Alexa(下)




版权申明:本站文章均来自网络,如有侵权,请联系我们,我们收到后立即删除,谢谢!

特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有。
  打印  刷新  关闭
返回首页 |关于我们 | 联系我们 | 付款方式 | 创业联盟 | 虚拟主机 | 资讯中心 | 友情链接 | 网站地图

版权所有 西部数码(www.west263.com)
CopyRight (c) 2002~2006 west263.com all right reserved.
公司地址:四川成都市万和路90号天象大厦4楼 邮编:610031
电话总机:028-86262244 86263048 86263408 86263960 86264018 86267838
售前咨询:总机转201 202 203 204 206 208
售后服务:总机转211 212 213 214
财务咨询:总机转224 223 传真:028-86264041 财务QQ:点击发送消息给对方635483282
售前咨询QQ:点击发送消息给对方2182518 点击发送消息给对方241975952 点击发送消息给对方275026793 点击发送消息给对方408235859
售后服务QQ:点击发送消息给对方17708515 点击发送消息给对方307742704 点击发送消息给对方287976517 点击发送消息给对方363783715
《中华人民共和国增值电信业务经营许可证》编号:川B2-20030065号