webmaster 发表于 2010-07-01, 11:14 PM.
发表在:
<%
Dim foldname,okstr
'自定义相对路径名
foldname= "db"
'自定义白名单后缀文件
okstr="rar,doc,xls,txt,mdb,asp"
If foldname = "" Then
foldname=geturlName()
urlfold=""
response.write foldname
Else
urlfold=foldname&"/"
End If
Call showfold(foldname)
Sub showfold(whichfold)
Dim Item, TheFolder, Files
OKAr = split(okstr,",")
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
If Fso.FolderExists(whichfold) = False Then
Response.write(whichfold + " 目录不存在或不允许访问!")
End If
Set TheFolder = Fso.GetFolder(whichfold)
Set Files = TheFolder.Files
For Each Item In Files
For Each str In OKAr
If InStr(Item.Name,str) Then
response.write ("<a href=./"&urlfold&Item.Name&" target=_blank>"&Item.Name& "</a><br>")
Exit for
Else
End If
Next
Next
Set Files = Nothing
Set TheFolder = Nothing
Set Fso = Nothing
End Sub
Function getfilefolder(filespec)
Dim fsoin, f, s
Set fsoin = CreateObject("Scripting.FileSystemObject")
Set f = fsoin.GetFile(filespec)
s = f.ParentFolder
getfilefolder = s
Set f=Nothing
Set fsoin=Nothing
End Function
Function geturlName()
Dim strURL,intPos,strFileName
strURL = Request.Servervariables("PATH_INFO")
intPos = InstrRev(strURL,"/")
strFileName = left(strURL,intPos)
geturlName = Replace(strFileName,"/","")
End Function
%>
上一篇:
printf函数调用时进栈的顺序及其特殊用法举例
下一篇:
感悟
|