ASP保存远程图片文件到本地代码
2008-11-22 18:22
691 查看
<IFRAME name=google_ads_frame marginWidth=0 marginHeight=0 src="http://pagead2.googlesyndication.com/pagead/ads?client=ca-pub-4490194096475053&dt=1227349296343&lmt=1226285505&prev_slotnames=1891601125&output=html&slotname=3685991503&correlator=1227349296312&url=http%3A%2F%2Fwww.corange.cn%2Farchives%2F2008%2F08%2F1565.html&ea=0&ref=http%3A%2F%2Fwww.corange.cn%2Fhtml%2Fcorange__90.html&frm=0&ga_vid=2091876339.1227189135&ga_sid=1227349233&ga_hid=96595439&ga_fc=true&flash=9.0.124.0&u_h=768&u_w=1024&u_ah=715&u_aw=1024&u_cd=32&u_tz=480&u_java=true&dtd=16" frameBorder=0 width=300 scrolling=no height=250 allowTransparency></IFRAME><%
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
%>
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
%>
相关文章推荐
- ASP保存远程图片文件到本地代码
- ASP保存远程图片到本地 同时取得第一张图片并创建缩略图的代码
- asp读取远程文件并保存到本地代码
- asp.net 怎么把远程图片保存为本地文件?
- ASP保存远程图片到本地 同时取得第一张图片并创建缩略图的代码
- asp读取远程文件并保存到本地代码
- asp下实现替换远程文件为本地文件并保存远程文件的代码
- asp下实现替换远程文件为本地文件并保存远程文件的代码
- ASP.NET下载远程图片保存到本地的方法、保存抓取远程图片
- 用ASP.NET实现下载远程图片保存到本地的方法 保存抓取远程图片的方法
- asp.net保存远程图片的代码
- ASP.NET下载远程图片保存到本地的方法、保存抓取远程图片
- php将远程图片保存到本地服务器的实现代码
- 用ASP.NET实现下载远程图片保存到本地的方法 保存抓取远程图片的方法
- 用ASP.NET实现下载远程图片保存到本地的方法 保存抓取远程图片的方法
- ASP使用xmlhttp和Adodb.Stream保存远程文件到本地
- 用php获取远程图片并把它保存到本地的代码
- [ASP通用类]替换远程文件为本地文件并保存远程文件
- 如何利用asp保存远程网页中的图片到本地来!