Loading...
  所在位置:论坛首页 -> ┈┋电脑网络技术区┋┈ -> Asp/Asp.Net技术 -> ASP处理文件上传以及删除时常用的自定义函数
标题:ASP处理文件上传以及删除时常用的自定义函数收藏 编辑 删除 楼主 | 上一篇 下一篇
有时也很傻
等级:社区游侠
权限:普通用户
积分:47
金钱:6304
声望:74
经验:74
发帖数:1524
注册:2007年10月26日
资料 短消息2008-4-8 10:42:18

asp 中处理文件上传以及删除时常用的自定义函数:

  <%
  ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  '所有自定义的VBS函数
  ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  function DeleteFile(Filename) '删除文件
  if Filename<>"" then
  Set fso = server.CreateObject("Scripting.FileSystemObject")
  if fso.FileExists(Filename) then
  fso.DeleteFile Filename
  end if
  set fso = nothing
  end if
  end function
  ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  function CreateDIR(byval LocalPath) '建立目录的程序,如果有多级目录,则一级一级的创建
  on error resume next
  LocalPath = replace(LocalPath,"\","/")
  set FileObject = server.createobject("Scripting.FileSystemObject")
  patharr = split(LocalPath,"/")
  path_level = ubound(patharr)
  for i = 0 to path_level
  if i=0 then pathtmp=patharr(0) & "/" else pathtmp = pathtmp & patharr(i) & "/"
  cpath = left(pathtmp,len(pathtmp)-1)
  if not FileObject.FolderExists(cpath) then FileObject.CreateFolder cpath
  next
  set FileObject = nothing
  if err.number<>0 then
  CreateDIR = false
  err.Clear
  else
  CreateDIR = true
  end if
  end function

 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  function SaveRandFileName(byval szFilename) '根据原文件名生成新的随机文件名
  randomize
  'ranNum=int(90000*rnd)+10000
  'if month(now)<10 then c_month="0" & month(now) else c_month=month(now)
  'if day(now)<10 then c_day="0" & day(now) else c_day=day(now)
  'if hour(now)<10 then c_hour="0" & hour(now) else c_hour=hour(now)
  'if minute(now)<10 then c_minute="0" & minute(now) else c_minute=minute(now)
  'if second(now)<10 then c_second="0" & second(now) else c_second=minute(now)
  fileExt_a=split(szFilename,".")
  fileExt=lcase(fileExt_a(ubound(fileExt_a)))

  SaveRandFileName=replace(replace(replace(now,":",""),"-","")," ","")&int(10*rnd)&"."&fileExt   
  'GenerateRandomFileName = year(now)&c_month&c_day&c_hour&c_minute&c_second&"_"&ranNum&"."&fileExt
  end function
  ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

 function jaron_replacer(strContent,start_string,end_string,replace_string)
  'CMS替换函数:源字符串,前部分,后部分,替换成的字符
  '返回被替换后的字符串
  jaron_replacer = replace(strContent,mid(strContent,instr(strContent,start_string),instr(strContent,end_string)+len(end_string)-1),replace_string)
  end function
  ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  function replaceplus(strContent,start_string,end_string,replace_string)
  '文档中,将所有开始,结束之间的所有字符删除
  on error resume next
  MARKCOUNTS = ubound(split(strContent,start_string))
  PRESTRING = strContent
  for i=0 to MARKCOUNTS
  STARTMARK=instr(1,PRESTRING,start_string,1)
  if STARTMARK=0 then exit for
  COMPMARK=instr(1,PRESTRING,end_string,1) + len(end_string)
  VerString=mid(PRESTRING,STARTMARK,COMPMARK - STARTMARK)
  PRESTRING = replace(PRESTRING,VerString,replace_string)
  next
  replaceplus = PRESTRING
  if err.number<>0 then err.Clear
  end function
  ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  %>

2008-4-8 10:42:18 顶部
第1页 共页 共0个回复     <<    >>    
 快速回复
  • 支持UBB,HTML标签

  • 高级回复

  • 操作选项:评分 加精 解精 奖惩 设专题 设公告 解公告 固顶 总固顶 解固顶 结帖 解结帖 锁帖 解锁 移帖 删帖
      首页 | 购买指南 | 商业版本 | 虚拟主机 | 特色介绍 | 下载中心 | 支付方式
    Copyright 2004-2008 BBSGood.com Powered By: BBSGood.Speed Version 5.0
      咨询电话:0575-85513832、0575-85513825(传真)、7*24小时咨询服务:13606552007 不良信息举报中心 浙ICP备05029817号
      业务QQ:38958768、客服QQ1:415896239、客服QQ2:343896043、MSN:jccsxx@hotmail.com