Custom functions commonly used in asp to handle file upload and deletion
<%
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'All custom VBS functions
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function DeleteFile(Filename) 'Delete file
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) 'The program that creates a directory. If there are multiple levels of directories, creates it one level at a time
on error resume next
LocalPath = replace(LocalPath,/,/)
set FileObject = server.createobject(Scripting.FileSystemObject)
patharr = split(LocalPath,/)
path_level = ubund(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) 'Generate new random file name based on the original file name
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(ubund(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 replacement function: source string, first part, last part, replaced characters
'Return the replaced string
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)