在ASP处理文件上传和删除时常用的自定义函数


<

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

所有的自定义VBS函数

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

函数删除一个文件(文件名)中删除文件

如果文件名,那么

设置FSO = server.createobject(脚本。FileSystemObject )

如果fso.fileexists(文件名)然后

fso.deletefile文件名

最后如果

设置FSO

最后如果

端功能

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

函数的CreateDIR(ByVal LocalPath)建立一个目录的程序,如果有多级目录,然后一级创作

下次继续出错

本地路径=取代(本地路径,

设置文件对象= server.createobject(脚本。FileSystemObject )

patharr =分(本地路径, / )

path_level = UBound(patharr)

我path_level = 0

如果我= 0然后pathtmp = patharr(0) / pathtmp = pathtmp patharr(我) /

cpath =左(pathtmp,len(pathtmp)- 1)

如果不fileobject.folderexists(cpath)然后fileobject.createfolder cpath

下一个

设置文件对象=没有

如果错误,数字<0,然后

createdir = false

呃。清晰

其他的

CreateDIR =真

最后如果

端功能

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

函数的SaveRandFileName(ByVal szfilename)产生的一种新的基于原始文件名随机文件名

随机化

rannum = int(90000 * Rnd)+ 10000

如果一个月(现在)<10然后c_month =0个月(现在的)其他c_month =月(现在)

如果有一天,(现在)<10然后c_day =0的日子(现在的)其他c_day =天(现在)

如果小时(现在)<10然后c_hour =0小时(现在的)其他c_hour =小时(现在)

如果一分钟(现在)<10然后c_minute =0分钟(现在的)其他c_minute =分钟(现在)

如果二(现在)<10然后c_second =0二(现在的)其他c_second =分钟(现在)

fileext_a =分裂(szfilename,,)

fileext = 1例(fileext_a(UBound(fileext_a)))


saverandfilename =替换(替换(现在,:

generaterandomfilename =年(现在)c_monthc_dayc_hourc_minutec_secondquot;_rannumquot;fileext 。

端功能

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

功能jaron_replacer(strcontent,start_string,end_string,replace_string)

CMS替换功能:源字符串、前面部分、后面部分和字符替换的字符。

返回替换字符串

jaron_replacer =取代(strcontent,中期(strcontent,仪器(strcontent,start_string),仪器(strcontent,end_string)+ len)

端功能

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

功能replaceplus(strcontent,start_string,end_string,replace_string)

在文档中,所有开始和结束之间的字符都被删除了。

下次继续出错

markcounts = UBound(分裂(strcontent,start_string))

strcontent=

我markcounts = 0

startmark =仪器(1,,start_string,1)

如果startmark = 0则退出

compmark =仪器(1,,end_string,1)+ len(end_string)

verstring =中(,startmark,compmark - startmark)

(=替代,verstring,replace_string)

下一个

replaceplus =

如果错误,数字<0,那么错误。

端功能

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

%>