'***************************************************************** '***************************************************************** '***************************************************************** '***************************************************************** '*****************************************************************
' function
' 作用 :利用流保存文件
' 参数 :from(远程文件地址),tofile(保存文件位置)
'*****************************************************************
private function savefiles(byref from,byref tofile)
dim datas
datas=getdata(from,0)
response.write "保存成功:<font color=red>"&formatnumber(len(datas)/1024*2,2)&"</font>kb"
response.flush
if formatnumber(len(datas)/1024*2,2)>1 then
ados.type = 1
ados.mode =3
ados.open
ados.write datas
ados.savetofile server.mappath(tofile),2
ados.close()
else
response.write "保存失败:<font color=red>文件大小"&formatnumber(len(imgs)/1024*2,2)&"kb,小于1k</font>"
response.flush
end if
end function
'*****************************************************************
' function(私有)
' 作用 :利用fso检测文件是否存在,存在返回true,不存在返回false
' 参数 :filespes(文件位置)
'*****************************************************************
private function isexists(byref filespec)
if (fso.fileexists(server.mappath(filespec))) then
isexists = true
else
isexists = false
end if
end function
' function(私有)
' 作用 :利用fso检测文件夹是否存在,存在返回true,不存在返回false
' 参数 :folder(文件夹位置)
'*****************************************************************
private function isfolder(byref folder)
if fso.folderexists(server.mappath(folder)) then
isfolder = true
else
isfolder = false
end if
end function
' function(私有)
' 作用 :利用fso创建文件夹
' 参数 :fldr(文件夹位置)
'*****************************************************************
private function createfolder(byref fldr)
dim f
set f = fso.createfolder(server.mappath(fldr))
createfolder = f.path
set f=nothing
end function
' function(公有)
' 作用 :保存文件,并自动创建多级文件夹
' 参数 :fromurl(远程文件地址),tofiles (保存位置)
'*****************************************************************
public function savedata(byref fromurl,byref tofiles)
tofiles=trim(replace(tofiles,"//","/"))
flname=tofiles
fldr=""
if isexists(flname)=false then
getnewsfold=split(flname,"/")
for i=0 to ubound(getnewsfold)-1
if fldr="" then
fldr=getnewsfold(i)
else
fldr=fldr&"\"&getnewsfold(i)
end if
if isfolder(fldr)=false then
createfolder fldr
end if
next
savefiles fromurl,flname
end if
end function
'*****************************************************************
' function(公有)
' 作用 :取得远程数据
' 参数 :url(远程文件地址),getmode (模式:0为二进制,1为中文编码)
'*****************************************************************
public function getdata(byref url,byref getmode)
'on error resume next
sourcecode = oxml.open ("get",url,false)
oxml.send()
if oxml.readystate<>4 then exit function
if getmode=0 then
getdata = oxml.responsebody
else
getdata = bytestobstr(oxml.responsebody)
end if
if err.number<>0 then err.clear
end function
' function(公有)
' 作用 :格式化远程图片地址为本地位置
' 参数 :imgurl(远程图片地址),imgfolder (本地图片目录),fristname(加入的前缀名称)
'*****************************************************************
public function formatimgpath(byref imgurl,byref imgfolder,byref fristname,byref noimg)
strpath=""
imgurl=imgurl
if instr(imgurl,"nophoto") or lenb(getdata(imgurl,0))<=0 then
strpath=noimg
response.write "<a href="&strpath&">"&strpath&"</a>" &vbcrlf
else
if instr(imgurl,".asp") then
strpath=fristname&"_"&mid(imgurl, instrrev(imgurl, "=")+1)&".jpg"
else
strpath=fristname&"_"&mid(imgurl, instrrev(imgurl, "/")+1)
end if
strpath = imgfolder&"/"&strpath
strpath = replace(strpath,"//","/")
if left(strpath,1)="/" then strpath=right(strpath,len(strpath)-1)
strpath = trim(strpath)
response.write "<a href="&strpath&">"&strpath&"</a>" &vbcrlf
savedata imgurl,strpath
end if
formatimgpath = strpath
end function
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器