📄 aa.asp
字号:
<%
Private Function save_img(img_url,fldr,fristname)
if instr(img_url,"http")=0 then
Response.Write "该图片保存失败" &vbcrlf
save_img=""
exit function
else
img_name_str = Replace(img_url,"\","/")
img_name_str = Replace(img_name_str,"//","/")
f_img_url = split(img_name_str,"/")
img_name = f_img_url(Ubound(f_img_url))
fldr ="/"&TlMyfile(fldr)&"/"
if img_name = "" then
img_name = f_img_url(Ubound(f_img_url)-1)
end if
set xmlhttp=server.createobject("Microsoft.XMLHTTP")
xmlhttp.open "get",img_url,false
xmlhttp.send
If xmlhttp.status = 200 Then
img=xmlhttp.ResponseBody
set objAdostream=server.createobject("ADODB.Stream")
objAdostream.type=1
objAdostream.Mode=3
objAdostream.Open()
objAdostream.Write(img)
objAdostream.SaveToFile(server.mappath(fldr&fristname&"_"&img_name))
Picgeturl = ""
objAdostream.SetEOS
set xmlhttp=nothing
set objAdostream=nothing
img_url=fldr&img_url
else
img_url = ""
exit function
end if
end if
end function
'*************************************************************************
'创建文件夹,返回函数TlMyfile,传递过程函数Myfile_Str_name
'*************************************************************************
Private Function TlMyfile(byref Myfile_Str)
Set Fso = Server.CreateObject("Scripting.FileSystemObject")
'GetFold=split(Myfile_Str,"/")
'if Fold_i = "0" to Ubound(GetFold)
if FSO.FolderExists(server.MapPath("./"&Myfile_Str&"")) Then
zj_FSO = True
else
Fso.CreateFolder(Server.Mappath("./"&Myfile_Str&""))
end if
Set Fso=Nothing
TlMyfile = Myfile_Str
end Function
url = "http://www.baidu.com/img/logo.gif/"
sss = "img"
pic = "pic"
%>
<%=save_img(url,sss,pic)%>
<%=TlMyfile(pic)%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -