如何把远端图片保存到本地?分不够再加!
求正确、可执行成功的源码,或解决方案,解决了问题,百分相送,分不够开新贴再加!谢谢。
------解决方案-------------------- <%
Function SaveRemoteFile(s_LocalFileName, s_RemoteFileUrl)
Dim Ads, Retrieval, GetRemoteData
Dim bError
bError = False
SaveRemoteFile = False
'On Error Resume Next
Set Retrieval = Server.CreateObject( "Microsoft.XMLHTTP ")
With Retrieval
.Open "Get ", s_RemoteFileUrl, False, " ", " "
.Send
GetRemoteData = .ResponseBody
End With
Set Retrieval = Nothing
If LenB(GetRemoteData) > nAllowSize*1024 Then
bError = True
Else
Set Ads = Server.CreateObject( "Adodb.Stream ")
With Ads
.Type = 1
.Open
.Write GetRemoteData
.SaveToFile Server.MapPath( "D:\ " & s_LocalFileName), 2
.Cancel()
.Close()
End With
Set Ads=nothing
End If
If Err.Number = 0 And bError = False Then
SaveRemoteFile = True
Else
Err.Clear
End If
End Function
If SaveRemoteFile( "123456.jpg ", "http://img.phoenixtv.com/tres/fashion/q05227.jpg ") Then
Response.write "OK "
Else
Response.write "NO "
End if
%>
------解决方案--------------------楼上的已经够详细了,我就不再发了
------解决方案--------------------XMLHTTP