当前位置: 首页 > 图文教程 > 网络编程 > ASP > 不用组件实现上载功能(1)

ASP
使用ASP中的VB ActiveX.dll文件
用ADO的COMMAND对象实现对WEB数据库动态数据查询的方法
在ASP中使用简单Java类
借助组件使用asp连接informix全方案
用ADSI编程实现IIS中建立虚拟目录
不刷新页面筛选数据库中的数据
使用ISAPI过滤器增强IIS的功能
利用J2ME与ASP建立数据库连接
用通ASP直接获取用户真实IP地址
用ASP编写计数器的优化方法
通过ASP远程注册自己的组件
检测IP地址是否真正合法的函数
用asp做access的远程接口
错误80004005信息处理方法
ASP学习:urldecode 方法补遗
在HTML页面中实现点击数统计
ASP字数计算函数
用ASP随机生成文件名的函数
单页面判断浏览器是否接受 Cookies
存储过程介绍及asp+存储过程的使用

ASP 中的 不用组件实现上载功能(1)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 41 ::
收藏到网摘: n/a

  '---- file name /upaoad.asp/

<%
Public Function BuildUploadRequest(strRequestBin)
    Dim PosBeg, PosEnd, boundary, boundaryPos
    'Get the boundary
    PosBeg = 1
    PosEnd = InstrB(PosBeg,strRequestBin,getByteString(chr(13)))
    boundary = MidB(strRequestBin,PosBeg,PosEnd-PosBeg)
    boundaryPos = InstrB(1,strRequestBin,boundary)

    'Get all data inside the boundaries
    Do until (boundaryPos = InstrB(strRequestBin,boundary & getByteString("--")))
        'Members variable of objects are put in a dictionary object
        Dim UploadControl
        Set UploadControl = CreateObject("Scripting.Dictionary")
        
        Dim Pos, Name
        'Get an object name
        Pos = InstrB(boundaryPos,strRequestBin,getByteString("Content-Disposition"))
        Pos = InstrB(Pos,strRequestBin,getByteString("name="))
        PosBeg = Pos + Len("name=") + 1
        PosEnd = InstrB(PosBeg,strRequestBin,getByteString(chr(34)))
        Name = getString(MidB(strRequestBin,PosBeg,PosEnd-PosBeg))

        Dim PosFile, PosBound, ContentType, Value
        'Test if object is of file type
        PosFile = InstrB(BoundaryPos,strRequestBin,getByteString("filename="))
        PosBound = InstrB(PosEnd,strRequestBin,boundary)

        If  PosFile <> 0 AND PosFile < PosBound Then
            'Get FilePathName of the file
            PosBeg = PosFile + Len("filename=") + 1
            PosEnd =  InstrB(PosBeg,strRequestBin,getByteString(chr(34)))
            FilePathName = getString(MidB(strRequestBin,PosBeg,PosEnd-PosBeg))
            
            'Add filename(with path) to dictionary object
            UploadControl.Add "FilePathName", FilePathName

            'Get Content-Type of the file
            Pos = InstrB(PosEnd,strRequestBin,getByteString("Content-Type:"))
            PosBeg = Pos + Len("Content-Type:") + 1
            PosEnd = InstrB(PosBeg,strRequestBin,getByteString(chr(13)))
            ContentType = getString(MidB(strRequestBin,PosBeg,PosEnd-PosBeg))

            'Add content-type to dictionary object
            UploadControl.Add "ContentType",ContentType
           &