ASP code Management code for files on space

Source: Internet
Author: User
Tags count end

<%
Aaa= "images/"------------folder path
Pagesize=3 '--------------The number of files displayed per page!
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%> '----folder loop begins
<%=s_folder.name%>
<% Next%>
<% for each F1 in F.files
If I>startnum then%> '----file loop start
<%= 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%> '---paging start
<a href= "/?page=1" > Home </a>
<% End If%>
<%if Page>1 then%>
<a href= "?page=<%=page-1%>" > Prev </a>
<% End If%>
<% If f.files.count=0 Then%>
There are no files in this directory!
<% Else%>
Total <%=f.files.count%> documents <%=page%>/<%=totalpage%> page
<% End If%>
<%if Page<totalpage then%>
<a href= "?page=<%=page+1%>" > next page </a>
<%end if%>
<%if Page<>totalpage then%>
<a href= "?page=<%=totalpage%>" > Last </a>
<%end if%> '----paging end
<% Set fs=nothing%>

<% '------------------------Delete file!
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 (' Delete success! '); Location.href (' page= "&page&");</script> "
End If
%>



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.