• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
    • 軟件測試技術
    • 軟件測試博客
    • 軟件測試視頻
    • 開源軟件測試技術
    • 軟件測試論壇
    • 軟件測試沙龍
    • 軟件測試資料下載
    • 軟件測試雜志
    • 軟件測試人才招聘
      暫時沒有公告

    字號: | 推薦給好友 上一篇 | 下一篇

    無組件實現文件上傳/下載

    發布: 2007-7-14 19:37 | 作者: 佚名    | 來源: 網絡轉載     | 查看: 16次 | 進入軟件測試論壇討論

    領測軟件測試網 ’==================================================================

    ’ 用ASP實現無組件上傳/下載文件

    ’ 功能簡介 
    ’ 將上傳的文件數據保存到數據庫中,可以處理表單中的多個上傳文件的情況
    ’ 適用于各種數據庫,使用ADO的方法連接數據庫
    ’ 本示例中使用的是ACCESS數據庫:zj.mdb
    ’ 表:tb_img(id int(自增列),path text(255) 保存上傳文件的目錄
    ’ ,fname text(250) 保存上傳的文件名,type test(250) 保存上傳文件的類型
    ’ ,img ole對象 保存上傳的文件內容

    ’ 
    ’==================================================================

    ’==================================================================

    ’ 上傳文件的HTML頁: zj_up.htm

    ’==================================================================
    <html>
    <head>
    <title>文件上傳保存到數據庫中</title>
    </head>
    <body>
    <form name="form1" enctype="multipart/form-data" method="post" action="zj_up.asp">
    <p>
    <input type="file" name="file">
    <input type="submit" name="Submit" value="上傳">
    </p>
    </form>
    </body>
    </html>

    ’==================================================================

    ’ 上傳文件保存到數據庫的ASP頁: zj_up.asp

    ’==================================================================
    <%
    Response.Expires=0
    Function f_Bin2Str(ByVal sBin)
    Dim iI, iLen, iChr, iRe 
    iRe = ""
    If Not IsNull(sBin) Then
    iLen = LenB(sBin)
    For iI = 1 To iLen
    iChr = MidB(sBin, iI, 1)
    If AscB(iChr) > 127 Then
    iRe = iRe & Chr(AscW(MidB(sBin, iI + 1, 1) & iChr))
    iI = iI + 1
    Else
    iRe = iRe & Chr(AscB(iChr))
    End If
    Next
    End If 
    f_Bin2Str = iRe
    End Function
    iConcStr = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False" & _ 
    ";Data Source=" & server.mappath("zj.mdb")
    iSql="tb_img"
    set iRe=Server.CreateObject("ADODB.Recordset")
    iRe.Open iSql,iConcStr,1,3
    iLen=Request.TotalBytes
    sBin=Request.BinaryRead(iLen)
    iCrlf1 = ChrB(13) & ChrB(10)
    iCrlf2 = iCrlf1 & iCrlf1
    iLen = InStrB(1, sBin, iCrlf1) - 1
    iSpc = LeftB(sBin, iLen)
    sBin = MidB(sBin, iLen + 34)
    iPos1 = InStrB(sBin, iCrlf2) - 1
    While iPos1 > 0
    iStr = f_Bin2Str(LeftB(sBin, iPos1))
    iPos1 = iPos1 + 5
    iPos2 = InStrB(iPos1, sBin, iSpc)

    iPos3 = InStr(iStr, "; filename=""") + 12
    If iPos3 > 12 Then
    iStr = Mid(iStr, iPos3)
    iPos3 = InStr(iStr, Chr(13) & Chr(10) & "Content-Type: ") - 2
    iFn = Left(iStr, iPos3)
    If iFn <> "" Then
    iRe.AddNew
    ire("path")=left(iFn,instrrev(iFn,"\")) 
    iRe("fname") = mid(iFn,instrrev(iFn,"\")+1)
    iRe("type") = Mid(iStr, iPos3 + 18)
    iRe("img").AppendChunk MidB(sBin, iPos1, iPos2 - iPos1)
    iRe.Update
    End If
    End If

    sBin = MidB(sBin, iPos2 + iLen + 34)
    iPos1 = InStrB(sBin, iCrlf2) - 1
    Wend
    iRe.close
    set iRe=Nothing
    %>
    ’==================================================================

    ’ 下載數據的ASP頁: zj_down.asp

    ’==================================================================
    <%
    Response.Buffer=true
    Response.Clear
    iConcStr = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False" & _ 
    ";Data Source=" & server.mappath("zj.mdb")
    set iRe=server.createobject("adodb.recordset")
    iSql="tb_img"
    iRe.open iSql,iconcstr,1,1
    Response.ContentType=ire("type")
    Response.BinaryWrite iRe("img")
    iRe.close
    set iRe=Nothing
    %>

    文章來源于領測軟件測試網 http://www.kjueaiud.com/


    關于領測軟件測試網 | 領測軟件測試網合作伙伴 | 廣告服務 | 投稿指南 | 聯系我們 | 網站地圖 | 友情鏈接
    版權所有(C) 2003-2010 TestAge(領測軟件測試網)|領測國際科技(北京)有限公司|軟件測試工程師培訓網 All Rights Reserved
    北京市海淀區中關村南大街9號北京理工科技大廈1402室 京ICP備10010545號-5
    技術支持和業務聯系:info@testage.com.cn 電話:010-51297073

    軟件測試 | 領測國際ISTQBISTQB官網TMMiTMMi認證國際軟件測試工程師認證領測軟件測試網

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>