首 页 ┆ 源码下载 ┆ IT学院 ┆ 字体下载 ┆ 模板下载 ┆ 源码发布 ┆ 广告合作 ┆ 网站地图 ┆ 虚拟主机 ┆ 中文域名
► 设为首页
► 加入收藏
► 联系我们
源码下载 >> ASP源码 | PHP源码 | ASP.net源码 | JSP源码 | CGI源码 | VC/C++源码 | VB源码 | Delphi源码 | Flash源码
文章学院 >> 网络编程 | 网页设计 | 图形图象 | 数据库 | 服务器 | 网络媒体 | 网络安全 | 操作系统 | 办公软件 | 软件开发 | 黑客知识
字体下载 >> 精制字体 | 非英字体 | 艺术字体 | 著名字体 | 哥特式 | 简单字体 | 手写体 | 节假日 | 图案字体 | 精度像素 | 中文字体
模板下载 >> 企业门户 | 数码网络 | 休闲娱乐 | 影视音乐 | 旅游名胜 | 文化艺术 | 电子商务 | 个性展示 | 登陆导航 | Flash模板
►►您当前的位置:源码园 → IT学院 → 网络编程 → ASP专区 → 文章内容

一个采集入库生成本地文件的几个FUCTION

作者:郁郁小蝎  来源:中国站长学院  发布时间:2007-2-6 12:54:53
'*****************************************************************
' 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


[] [返回上一页] [打 印]
  • 上一篇文章:浅谈ASP中Web页面间的数据传递
  • 下一篇文章:微软建议的ASP性能优化28条守则(1)

  • 相关文章:
  • JSP Actions的使用
  • Action 造成cpu占用过多的奇怪问题
  • Delphi中TApplication类的巧用
  • <C++实践系列>C++中的虚函数(virtual function)
  • <C++实践系列>C++中的异常(exception)
  • [图文]串行化(Serialization)
  • [组图]XP改造成Media Center Edition
  • [组图]系统DIY XP变身Media Center Edition
  • IBM现提供免费Software Evaluation Kit(SEK) DVD
  • 为什么apache配置文件里的Options属性没有得到预期的...
  • Mac OS X 10.2 Option+Command+拖曳
  • configuration utility for the RAIDframe disk dri...
关于本站 - 网站帮助 - 广告合作 - 下载声明 - 友情连接 - 网站地图 - 源码发布
Copyright © 2003-2009 Ymyasp.Com. All Rights Reserved .
备案序号:粤ICP备07029071号