zoukankan      html  css  js  c++  java
  • ASP保存远程图片文件到本地代码

    <% 
    Function SaveRemoteFile(LocalFileName,RemoteFileUrl) 
    SaveRemoteFile=True 
    dim Ads,Retrieval,GetRemoteData 
    Set Retrieval = Server.CreateObject("Microsoft.XMLHTTP") 
    With Retrieval 
    .Open "Get", RemoteFileUrl, False, "", "" 
    .Send 
    If .Readystate<>4 then 
    SaveRemoteFile=False 
    Exit Function 
    End If 
    GetRemoteData = .ResponseBody 
    End With 
    Set Retrieval = Nothing 
    Set Ads = Server.CreateObject("Adodb.Stream") 
    With Ads 
    .Type = 1 
    .Open 
    .Write GetRemoteData 
    .SaveToFile server.MapPath(LocalFileName),2 
    .Cancel() 
    .Close() 
    End With 
    Set Ads=nothing 
    End Function 
    %> 
    
    <% 
    '以下为调用示例: 
    remoteurl="http://www.yiwu-jewelry.cn/images_yiwu/logo.jpg"'远程文件名(绝对全路径) 
    localfile="images/"&Replace(Replace(Replace(Now(),"-","")," ",""),":","")&Right(remoteurl,4)'本机文件名(可自定义) 
    If SaveRemoteFile(localfile,remoteurl)=True Then 
    Response.Write("成功保存:"&localfile) 
    End If 
    %> 
    

      

  • 相关阅读:
    104每日博客
    924每日博客
    921每日博客
    928每日博客
    929每日博客
    930每日博客
    927每日博客
    大志非才不就,大才非学不成—我的博文资源汇总
    vue 项目搭建
    Vant 使用记录
  • 原文地址:https://www.cnblogs.com/uuxanet/p/3282908.html
Copyright © 2011-2022 走看看