<%
aaa="images/" ' ------------檔案夾路徑
pagesize=3 '--------------每頁顯示的檔案數!
totalpage=1
page=trim(request.querystring("page"))
if page<>"" and isnumeric(page) then
page=fix(page)
else
page=1
end if
Set fs = CreateObject("Scripting.FileSystemObject")
sPathFile=""&aaa&""
Set f = fs.GetFolder(Server.MapPath(sPathFile))
if f.files.count mod pagesize=0 then
totalpage=f.files.count\pagesize
else
totalpage=f.files.count\pagesize+1
end if
if page<1 then
page=1
end if
if page>totalpage then
page=totalpage
end if
i=1
startnum=(page-1)*pagesize%>
<% For Each s_folder in f.subfolders %>'----檔案夾迴圈開始
<%=s_folder.name%>
<% next %>
<% For Each f1 in f.Files
if i>startnum then %>'----檔案迴圈開始
<%= f1.name%><%= f1.size%><%= f1.type%><%= f1.datelastmodified%>
<%
end if
if i>startnum+pagesize then
exit for
end if
i=i+1
next
%>
<%if page>1 then %>'---分頁開始
<a href="/?page=1">首頁</a>
<% end if %>
<%if page>1 then %>
<a href="?page=<%=page-1%>">上一頁</a>
<% end if %>
<% If f.files.count=0 Then %>
此目錄下沒有檔案!
<% Else %>
共<%=f.files.count%>個檔案 第<%=page%> / <%=totalpage%>頁
<% End If %>
<%if page<totalpage then%>
<a href="?page=<%=page+1%>">下一頁</a>
<%end if %>
<%if page<>totalpage then%>
<a href="?page=<%=totalpage%>">尾頁</a>
<%end if %>'----分頁結束
<% set fs=nothing %>
<%'------------------------刪除檔案!
If request("action")="del_upfilename" Then
del_upfilename=request("del_upfilename")
set fileobj=server.createobject("scripting.filesystemobject")
if fileobj.FileExists(server.mappath(del_upfilename)) then
fileobj.DeleteFile(server.mappath(del_upfilename))
end if
set fileobj=nothing
response.write "<script language=javascript>alert('刪除成功!');location.href('?page="&page&"');</script>"
end if
%>