Processing file upload and delete custom functions

xiaoxiao2021-03-06  89

<%

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

'All custom VBS functions

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

Function deletefile (filename) 'Delete file

IF filename <> "" "" "

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) 'Creating a directory, if there is a multi-level directory, create a level first level

ON Error ResMe 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) "Generates a new random file name according to the original file name

randomize

'rannum = int (90000 * rND) 10000

'IF Month (now) <10 TEN C_MONTH = "0" & ​​Month (now) else c_month = month (now)

'if day (now) <10 TEN C_DAY = "0" & ​​day (now) else c_day = day (now)

'IF Hour (now) <10 TEN C_HOUR = "0" & ​​HOUR (now) else c_Hour = Hour (now)

'IF minute (now) <10 TEN C_MINUTE = "0" & ​​minute (now) else c_minute = minute (now)

'if second (now) <10 TEN C_SECOND = "0" & ​​second (now) else c_second = minute (now)

FILEEXT_A = Split (SZFileName, ".")

FILEEXT = LCase (fileext_a (ubound (fileext_a)))

SaverandFileName = Replace (Replace (now, ",", ",", ",", ",") & int (10 * rND) & "." & Fileext

'Generatingrandomfilename = year (now) & c_month & c_day & c_Hour & C_Minute & C_Second & "& Rannum &". "& FileExtend Function

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

Function Jaron_replace (strcontent, start_string, end_string, replace_string)

'CMS replacement function: Source string, front part, back part, replaceable characters

'Returns the replaced string

Jaron_replace = Replace (StrContent, STRCONTENT, INSTR (Str ", INSTR (STRCONTENT, END_STRING) LEN (End_String) -1), Replace_String)

END FUNCTION

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

Function ReplacePlus (StrContent, Start_String, End_String, Replace_String)

In 'documentation, all characters between the beginning, the end, end

ON Error ResMe 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 = preStringif Err.Number <> 0 Then Err.clear

END FUNCTION

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

%>

转载请注明原文地址:https://www.9cbs.com/read-103740.html

New Post(0)