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

ASP
ASP系列讲座(十)ASP 内建对象
ASP系列讲座(十一)ActiveX 组件
ASP系列讲座(十二)向浏览器发送内容
ASP系列讲座(十三)向浏览器传送脚本
ASP系列讲座(十四)包含文件
ASP系列讲座(十五)使用 HTML 表格
ASP系列讲座(十六)访问数据库
ASP系列讲座(十七)调试 ASP 脚本
ASP系列讲座(十八)管理应用程序
ASP系列讲座(十九)管理会话
ASP系列讲座(二十)维护 ASP 应用程序的安全
ASP系列讲座(二十一)创建事务性脚本
ASP系列讲座(二十二)使用国际站点
ASP系列讲座(二十三)编写跨平台应用程序
利 用 ISAPI 实 现 向 数 据 库 中 添 加 记 录 (一)
利 用 ISAPI 实 现 向 数 据 库 中 添 加 记 录 (二)
利 用 ISAPI 实 现 向 数 据 库 中 添 加 记 录 (三)
利 用 ISAPI 实 现 向 数 据 库 中 添 加 记 录 (四)
利 用 ISAPI 实 现 向 数 据 库 中 添 加 记 录 (五)
利 用 ISAPI 实 现 向 数 据 库 中 添 加 记 录 (六)

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 49 ::
收藏到网摘: 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
           &