• <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 | 作者: 佚名    | 來源: 網絡轉載     | 查看: 26次 | 進入軟件測試論壇討論

    領測軟件測試網 <%
    '------------------------------------------------------------------------
    '-------------------無垠網域:http://www.5inet.net/ ---------------------
    '-------------------作者:嘻哈呵嘿 ,webmaster@5inet.net -----------------
    '----------遠程獲取內容,并將內容存在本地電腦上,包括任何文件!----------
    '---------------利用xmlhttp和adodb.stream,酷!絕對原創!-----------------
    'On Error Resume Next
    'Set the content type to the specific type that you are sending.
    'Response.ContentType = "IMAGE/JPEG"
    '-------------------------------定義輸出格式-----------------------------

    Path=request.querystring("p")
    sPath = Path
    if left(lcase(path),7) <> "http://" then
    '-------------如果前面沒有http就是本地文件,交給LocalFile處理------------
    LocalFile(path)
    else
    '--------------------否則為遠程文件,交給RemoteFile處理------------------
    RemoteFile(Path)
    end if
    'Response.Write err.Description

    sub LocalFile(Path)
    '-------------------如果為本地文件則簡單的跳轉到該頁面-------------------
    Response.Redirect Path
    End Sub

    Sub RemoteFile(sPath)
    '-------------------------處理遠程文件函數------------------------------
    FileName = GetFileName(sPath)
    '-------------GetFileName為把地址轉換為合格的文件名過程-------------
    FileName = Server.MapPath("/UploadFile/Cache/" & FileName)
    Set objFso = Server.CreateObject("Scripting.FileSystemObject")
    'Response.Write fileName
    if objFso.FileExists(FileName) Then
    '--------------檢查文件是否是已經訪問過,如是,則簡單跳轉------------
    Response.Redirect "/uploadfile/cache/" & GetFileName(path)
    Else
    '----------------否則的話就先用GetBody函數讀取----------------------
    'Response.Write Path
    t = GetBody(Path)
    '-----------------用二進制方法寫到瀏覽器上--------------------------
    Response.BinaryWrite t
    Response.Flush
    '-----------------輸出緩沖------------------------------------------
    SaveFile t,GetFileName(path)
    '------------------將文件內容緩存到本地路徑,以待下次訪問-----------
    End if
    Set objFso = Nothing
    End Sub

    Function GetBody(url)
    '-----------------------本函數為遠程獲取內容的函數---------------------
    'on error resume next
    'Response.Write url
    Set Retrieval = CreateObject("Microsoft.XMLHTTP")
    '----------------------建立XMLHTTP對象-----------------------------
    With Retrieval
    .Open "Get", url, False, "", ""
    '------------------用Get,異步的方法發送-----------------------
    .Send
    'GetBody = .ResponseText
    GetBody = .ResponseBody
    '------------------函數返回獲取的內容--------------------------
    End With
    Set Retrieval = Nothing
    'response.Write err.Description
    End Function

    Function GetFileName(str)
    '-------------------------本函數為合格化的文件名函數-------------------
    str = Replace(lcase(str),"http://","")
    str = Replace(lcase(str),"http://","/")
    str = Replace(str,"/","")
    str = replace(str,vbcrlf,"")
    GetFileName = str
    End Function

    sub SaveFile(str,fName)
    '-------------------------本函數為將流內容存盤的函數-------------------
    'on error resume next
    Set objStream = Server.CreateObject("ADODB.Stream")
    '--------------建立ADODB.Stream對象,必須要ADO 2.5以上版本---------
    objStream.Type = adTypeBinary
    '-------------以二進制模式打開-------------------------------------
    objStream.Open
    objstream.write str
    '--------------------將字符串內容寫入緩沖--------------------------
    'response.Write fname
    objstream.SaveToFile "c:\inetpub\myweb\uploadfile\cache\" & fName,adSaveCreateOverWrite
    '--------------------將緩沖的內容寫入文件--------------------------
    'response.BinaryWrite objstream.Read
    objstream.Close()
    set objstream = nothing
    '-----------------------關閉對象,釋放資源-------------------------
    'response.Write err.Description
    End sub
    %>


    延伸閱讀

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


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