<!--#include file="paths.asp"-->
<%
set fso=CreateObject("Scripting.FileSystemObject")
if request("Action")="Del" then
whichfile=Request("FileName")
Set thisfile = fso.GetFile(whichfile)
thisfile.Delete True
response.Redirect "pic.asp" '文件删除后,重新返回当前页面
end if
%>
<%
Response.Write "<table cellspacing=1 cellpadding=0 align=center bgcolor=#666666 bordercolor=#000000 border=0>"
Response.Write "<tr bgcolor=#33CCCC>"
Response.Write " <td>ID</td>"
Response.Write " <td>文件</td>"
Response.Write " <td>文件大小</td>"
Response.Write " <td>创建日期</td>"
Response.Write " <td>操作</td>"
Response.Write "</tr>"
FoldPath=npath
set fso = Server.CreateObject("Scripting.FileSystemObject")
'得到目录下所有文件的信息集合
set fsoFolder=fso.GetFolder(FoldPath)
Set GetFiles =fsoFolder.files
'定义数组,和变量
Dim FileArr(),i,p,Max,OrderBy,Total,MoveAddRessStart,MoveAddRessEnd,PCount,PFSize,APFSize
Max = 20'默认的显示条数
orderBy="DESC"'排序方式,DESC倒序,ASC正序
'得到大于0的页码
P = Request.QueryString("P")
IF P <> "" Then
If IsNumeric(P) Then
IF Cint(P) > 0 Then
P = Cint(P)
Else
P = 1
End If
Else
P = 1
End IF
Else
P = 1
End IF
'定义了文件总数的数组,0为文件名,1为日期时间,2为文件大小
ReDim FileArr(Getfiles.count-1,2)
i = 0
For Each f In GetFiles
IF FilterName(Lcase(f.Name)) Then
'取出文件名
FileArr(i,0) = f.Name
'取出文件建立时间
FileArr(i,1) = f.DateCreated
FileArr(i,2) = f.Size
APFSize=APFSize+f.Size
i = i + 1
End IF
Next
'得到总页数
Total=i
IF Total Mod Max = 0 Then
PCount = ToTal / Max
Else
PCount = Total \ Max + 1
End IF
IF P > PCount Then P = PCount
'对文件进行排序按日期,OrderBy等于DESC倒序,OrderBy等于ASC正序
For One = 0 To i - 1
For Two = 0 To i - 1
IF Ucase(OrderBy) = "DESC" Then
orderByConditions=(CDate(FileArr(One,1)) > CDate(FileArr(Two,1)))
ElseIF Ucase(OrderBy) = "ASC" Then
orderByConditions=(CDate(FileArr(One,1)) < CDate(FileArr(Two,1)))
End IF
'对文件进行排序按日期,OrderBy等于DESC倒序,OrderBy等于ASC正序
For One = 0 To i - 1
For Two = 0 To i - 1
IF Ucase(OrderBy) = "DESC" Then
orderByConditions=(CDate(FileArr(One,1)) > CDate(FileArr(Two,1)))
ElseIF Ucase(OrderBy) = "ASC" Then
orderByConditions=(CDate(FileArr(One,1)) < CDate(FileArr(Two,1)))
End IF
IF orderByConditions Then
TempName = FileArr(Two,0)
TempTime = FileArr(Two,1)
TempSize = FileArr(Two,2)
FileArr(Two,0) = FileArr(One,0)
FileArr(Two,1) = FileArr(One,1)
FileArr(Two,2) = FileArr(One,2)
FileArr(One,0) = TempName
FileArr(One,1) = TempTime
FileArr(One,2) = TempSize
End IF
Next
Next
'得到当前页的文件位置,开始地址如果为第一页则其实位置是0,因为数组的下限是0
MoveAddRessStart = P * Max - Max
IF (i-1-Max) > MoveAddRessStart Then
MoveAddRessEnd=MoveAddRessStart+Max-1
Else
MoveAddRessEnd=(i-1)-1
End IF
'Response.write Total
'显示列表
For j = MoveAddRessStart To MoveAddRessEnd
'Response.Write FileArr(j,2)&filearr(j,0):response.end
Response.Write "<tr><td bgcolor=#ffffff>" & j & "</td><td bgcolor=#ffffff>"%>
<IMG SRC="../tb/<%=FileArr(j,0) %>" >
<%response.Write "</td><td bgcolor=#ffffff>" & SizeTo(FileArr(j,2)) & "</td><td bgcolor=#ffffff>"&FileArr(j,1)&"</td><td><a href='?Action=Del&FileName="&npath&FileArr(j,0)&"'>删除</a></td></tr>"
PFSize = PFSize + FileArr(j,2)
Next
Response.Write "<tr><td bgcolor=#ffffff colspan=4 align=right>"
Response.Write "当前页有" & MoveAddRessEnd-MoveAddRessStart+1 & "个文件 "
Response.Write "占用空间" & SizeTo(PFSize) & " "
IF P > 1 Then
Response.Write "<a href=?p=1>首页</a> <a href=?p="&p-1&">上一页</a> "
Else
Response.Write "首页 上一页 "
End IF
TempName = FileArr(Two,0)
TempTime = FileArr(Two,1)
TempSize = FileArr(Two,2)
FileArr(Two,0) = FileArr(One,0)
FileArr(Two,1) = FileArr(One,1)
FileArr(Two,2) = FileArr(One,2)
FileArr(One,0) = TempName
FileArr(One,1) = TempTime
FileArr(One,2) = TempSize
End IF
Next
Next
'得到当前页的文件位置,开始地址如果为第一页则其实位置是0,因为数组的下限是0
MoveAddRessStart = P * Max - Max
IF (i-1-Max) > MoveAddRessStart Then
MoveAddRessEnd=MoveAddRessStart+Max-1
Else
MoveAddRessEnd=(i-1)-1
End IF
'Response.write Total
'显示列表
For j = MoveAddRessStart To MoveAddRessEnd
'Response.Write FileArr(j,2)&filearr(j,0):response.end
Response.Write "<tr><td bgcolor=#ffffff>" & j & "</td><td bgcolor=#ffffff>"%>
<IMG SRC="../tb/<%=FileArr(j,0) %>" >
<%response.Write "</td><td bgcolor=#ffffff>" & SizeTo(FileArr(j,2)) & "</td><td bgcolor=#ffffff>"&FileArr(j,1)&"</td><td><a href='?Action=Del&FileName="&npath&FileArr(j,0)&"'>删除</a></td></tr>"
PFSize = PFSize + FileArr(j,2)
Next
Response.Write "<tr><td bgcolor=#ffffff colspan=4 align=right>"
Response.Write "当前页有" & MoveAddRessEnd-MoveAddRessStart+1 & "个文件 "
Response.Write "占用空间" & SizeTo(PFSize) & " "
IF P > 1 Then
Response.Write "<a href=?p=1>首页</a> <a href=?p="&p-1&">上一页</a> "
Else
Response.Write "首页 上一页 "
End IF
IF P < PCount Then
Response.Write "<a href=?p="&P+1&">下一页</a> <a href=?p="&PCount&">尾页</a> "
Else
Response.Write "下一页 尾页 "
End IF
Response.Write P&"/"&PCount&"页 "
Response.Write "共有"&Total&"个文件 "
Response.Write "共" & SizeTo(APFSize) & " "
Response.Write "</td></tr>"
Response.WRite "</table>"
'过滤文件扩展名
Function FilterName(FileName)
Dim Filter_Expansion_Name,ExpansionName
Filter_Expansion_Name = "|asp|htm|jpg|jpeg|gif|swf|bmp|png|"'过滤取得文件夹中的文件类型,如果只填写htm则只取htm文件,注意文件本身不会出现在这个表中,但会计算在总数中
'得到扩展名
For Tp= Len(FileName) To 1 Step -1
IF Mid(FileName,Tp,1) = "." Then
Exit For
Else
ExpansionName = Mid(FileName,Tp,1) & ExpansionName
End IF
Next
Response.Write "<a href=?p="&P+1&">下一页</a> <a href=?p="&PCount&">尾页</a> "
Else
Response.Write "下一页 尾页 "
End IF
Response.Write P&"/"&PCount&"页 "
Response.Write "共有"&Total&"个文件 "
Response.Write "共" & SizeTo(APFSize) & " "
Response.Write "</td></tr>"
Response.WRite "</table>"
'过滤文件扩展名
Function FilterName(FileName)
Dim Filter_Expansion_Name,ExpansionName
Filter_Expansion_Name = "|asp|htm|jpg|jpeg|gif|swf|bmp|png|"'过滤取得文件夹中的文件类型,如果只填写htm则只取htm文件,注意文件本身不会出现在这个表中,但会计算在总数中
'得到扩展名
For Tp= Len(FileName) To 1 Step -1
IF Mid(FileName,Tp,1) = "." Then
Exit For
Else
ExpansionName = Mid(FileName,Tp,1) & ExpansionName
End IF
Next
IF Instr(1,Filter_Expansion_Name,"|" & ExpansionName & "|")>0 Then
FilterName=True
Else
FilterName=False
End If
End Function
' 转换文件大小转换
Function SizeTo(PFSize)
SizeTo=0
IF PFSize>(1024*1024*1024) And (PFSize/1024/1024/1024)>0 Then
'GB转换
SizeTo=FormatNumber(PFSize/1024/1024/1024,2)&"GB"
ElseIF PFSize>(1024*1024) And (PFSize/1024/1024)>0 Then
'MB转换
SizeTo=FormatNumber(PFSize/1024/1024,2)&"MB"
ElseIF PFSize>1024 And (PFSize/1024)>0 Then
'KB转换
SizeTo=FormatNumber(PFSize/1024,2)&"KB"
ElseIF PFSize>0 Then
'byte转换
SizeTo=FormatNumber(PFsize,2)&"B"
Else
SizeTo=0&"B"
End IF
End Function
%>
FilterName=True
Else
FilterName=False
End If
End Function
' 转换文件大小转换
Function SizeTo(PFSize)
SizeTo=0
IF PFSize>(1024*1024*1024) And (PFSize/1024/1024/1024)>0 Then
'GB转换
SizeTo=FormatNumber(PFSize/1024/1024/1024,2)&"GB"
ElseIF PFSize>(1024*1024) And (PFSize/1024/1024)>0 Then
'MB转换
SizeTo=FormatNumber(PFSize/1024/1024,2)&"MB"
ElseIF PFSize>1024 And (PFSize/1024)>0 Then
'KB转换
SizeTo=FormatNumber(PFSize/1024,2)&"KB"
ElseIF PFSize>0 Then
'byte转换
SizeTo=FormatNumber(PFsize,2)&"B"
Else
SizeTo=0&"B"
End IF
End Function
%>
没有评论:
发表评论