UpPicFile.asp
上传用户:dbstep
上传日期:2022-08-06
资源大小:2803k
文件大小:9k
源码类别:

WEB源码(ASP,PHP,...)

开发平台:

ASP/ASPX

  1. <HTML xmlns="http://www.w3.org/1999/xhtml">
  2. <HEAD>
  3. <TITLE>图片管理</TITLE>
  4. <link rel="stylesheet" href="Images/CssAdmin.css">
  5. <script language="javascript" src="../skweb/JS/Admin.js"></script>
  6. </HEAD>
  7. <!--#include file="../skweb/Const.asp" -->
  8. <!--#include file="../skweb/ConnSiteData.asp" -->
  9. <!--#include file="CheckAdmin.asp"-->
  10. <%
  11. if Instr(session("AdminPurview"),"|72,")=0 then 
  12.   response.write ("<font color='red')>你不具有该管理模块的操作权限,请返回!</font>")
  13.   response.end
  14. end if
  15. '========判断是否具有管理权限
  16. %>
  17. <BODY>
  18. <%
  19. Const FsoString="Scripting.FileSystemObject" 'FSO字符串
  20. PageSize=15  '每页显示数
  21. Function ShowPage(ByRef PageCount,RecordCount,CurrentPage,PageSize,LinkFile)
  22. Dim Retval,J,StartPage,EndPage
  23. If (RecordCount Mod PageSize)=0 Then
  24.     PageCount=RecordCount  PageSize
  25. Else 
  26.     PageCount=RecordCount  PageSize+1
  27. End If
  28. If PageCount=0 Then PageCount=1
  29. If CurrentPage="" Then CurrentPage=1 else CurrentPage=CInt(CurrentPage)
  30. Retval=Retval & "<table Width='100%' border='0' cellspacing='0' cellpadding='0' bgcolor='#D7E4F7'>"
  31.     Retval=Retval & "<tr>"
  32.     Retval=Retval & "<td>"
  33. If CurrentPage=1 Then              
  34. Retval=Retval & "&nbsp;<font style='color:#000000'>首页</font> | <font style='color:#000000'>前页</font> | " 
  35. Else
  36. Retval=Retval & "<a href='" & LinkFile & "Page=1'>首页</a> | <a href='" & LinkFile & "Page=" & CurrentPage - 1 & "'>前页</a> | "
  37. End If
  38. If  CurrentPage=PageCount Then             
  39. Retval=Retval & "<font style='color:#000000'>后页</font> | <font style='color:#000000'>末页</font>"
  40. Else
  41. Retval=Retval & "<a href='" & LinkFile & "Page=" & CurrentPage + 1 & "'>后页</a> | <a href='" & LinkFile & "Page=" & PageCount & "'>末页</a>"
  42. End if
  43. If RecordCount>0 Then
  44.     Retval=Retval & " | <b>"&CurrentPage&"</b>页/<b>"&CInt(PageCount)&"</b>页 | 共<b>"&RecordCount&"</b>条记录"
  45. End If
  46. Retval=Retval & "<td align='right'>"
  47. StartPage = Page-3
  48. EndPage = Page+3
  49. If StartPage<=0 Then
  50.     StartPage=1
  51. ElseIf StartPage>1 Then 
  52.     Retval=Retval & " <a href='" & LinkFile & "Page=1' style='font-family:webdings' title='首页'>9</a>"
  53.     Retval=Retval & " ... "
  54. End If     
  55. If EndPage>PageCount Then EndPage=PageCount
  56. For J = StartPage to EndPage
  57. If J = Page Then
  58.     Retval = Retval & " <font color=#999999>" & J & "</font>"
  59. Else
  60.     Retval = Retval & " <a href='" & LinkFile & "Page=" & J & "'>" & J & "</a>"
  61. End If
  62. Next
  63. If EndPage < PageCount Then Retval= Retval & " ... <a href='" & LinkFile & "Page=" & PageCount & "' style='font-family:webdings' title='末页'>:</a>"
  64. Retval=Retval & "</td>"
  65. Retval=Retval & "</tr>"
  66.     Retval=Retval & "</table>"
  67. ShowPage=Retval
  68. End Function
  69. Dim Action,Sfor(30,2)
  70. Call Main()
  71. Sub Main()
  72.     Dim objFSO,Uploadpath,FileName
  73.     Dim Folder
  74.     Dim Num,FileCount
  75.     If Request("Path")<>"" Then
  76.         UploadPath=Request("Path")
  77.     Else 
  78.         UploadPath="../Upload/PicFiles"
  79.     End If
  80.     sFor(0,0)="txt":sFor(0,1)="txt"
  81.     sFor(1,0)="chm":sFor(1,1)="chm"
  82.     sFor(2,0)="hlp":sFor(2,1)="chm"
  83.     sFor(3,0)="doc":sFor(3,1)="doc"
  84.     sFor(4,0)="pdf":sFor(4,1)="pdf"
  85.     sFor(5,0)="gif":sFor(5,1)="gif"
  86.     sFor(6,0)="jpg":sFor(6,1)="jpg"
  87.     sFor(7,0)="png":sFor(7,1)="png"
  88.     sFor(8,0)="bmp":sFor(8,1)="bmp"
  89.     sFor(9,0)="asp":sFor(9,1)="asp"
  90.     sFor(10,0)="jsp":sFor(10,1)="asp"
  91.     sFor(11,0)="js" :sFor(11,1)="asp"
  92.     sFor(12,0)="htm":sFor(12,1)="html"
  93.     sFor(13,0)="html":sFor(13,1)="html"
  94.     sFor(14,0)="shtml":sFor(14,1)="html"
  95.     sFor(15,0)="zip":sFor(15,1)="zip"
  96.     sFor(16,0)="rar":sFor(16,1)="rar"
  97.     sFor(17,0)="exe":sFor(17,1)="exe"
  98.     sFor(18,0)="avi":sFor(18,1)="avi"
  99.     sFor(19,0)="mpg":sFor(19,1)="mpg"
  100.     sFor(20,0)="ra" :sFor(20,1)="ra"
  101.     sFor(21,0)="ram":sFor(21,1)="ra"
  102.     sFor(22,0)="mid":sFor(22,1)="mid"
  103.     sFor(23,0)="wav":sFor(23,1)="wav"
  104.     sFor(24,0)="mp3":sFor(24,1)="mp3"
  105.     sFor(25,0)="asf":sFor(25,1)="asf"
  106.     sFor(26,0)="php":sFor(26,1)="aspx"
  107.     sFor(27,0)="php3":sFor(27,1)="aspx"
  108.     sFor(28,0)="aspx":sFor(28,1)="aspx"
  109.     sFor(29,0)="xls":sFor(29,1)="xls"
  110.     sFor(30,0)="mdb":sFor(30,1)="mdb"
  111. %>
  112. <table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#CCCCCC">
  113.   <tr>
  114.     <td height="29" nowrap background="Images/menutitle.gif"><table width="470" border="0" cellspacing="0" cellpadding="0">
  115.       <tr>
  116.         <td width="121"><strong><font color="#000000" size="2">网站附件管理</font></strong></td>
  117.         <td width="87"><a href="admigql.asp"><img src="Images/xxql.gif" width="52" height="17" border="0"></a></td>
  118.         <td width="87"><a href="UpPicFile.asp"><img src="Images/xxsy.gif" width="52" height="17" border="0"></a></td>
  119.         <td width="87"></td>
  120.         <td width="88"></td>
  121.       </tr>
  122.     </table></td>
  123.   </tr>
  124. <tr><td bgcolor="#EBF2F9">
  125.   <table Width="100%" border=0 align="center" cellpadding=0 cellspacing=0 bgcolor="#EBF2F9" class=border-all>
  126.   <tr>
  127.     <td height="3" nowrap></td>
  128.   </tr>
  129.   <form name="form1" method="get" action="?path=">
  130.     <tr> 
  131.       <td height="25" sytle="line-height:150%">&nbsp;目录浏览&nbsp;&nbsp;要查看的文件夹: 
  132.         <input name="path" type="text" class="editbox" id="path"> <input name="Submit" type="submit" class="button" value="提交">
  133.       <font color="#666666"><b>&nbsp;请填写正确的文件夹名或路径</b></font></td>
  134.     </tr>
  135.     <tr> 
  136.       <td height="20" sytle="line-height:150%">&nbsp;当前浏览 <font style="color:#666666;font-weight:bold"><%=server.mappath(uploadpath)%></font> 目录的所有文件列表如下</td>
  137.     </tr>
  138.   </form>
  139. </table>
  140. </td></tr></table>
  141. <br>
  142. <table Width="100%" border="0" align=center cellpadding="5" cellspacing="1" bgcolor="#CCCCCC">
  143.   <tr bgcolor="#8DB5E9"> 
  144.     <td Width="6%" height=23 align="center" background="Images/tn.gif"><span class="style8">类型</span></td>
  145.     <td Width="51%" align="center" background="Images/tn.gif"><span class="style8">文件地址</span></td>
  146.     <td Width="13%" align="center" background="Images/tn.gif"><span class="style8">大小</span></td>
  147.     <td Width="23%" align="center" background="Images/tn.gif"><span class="style8">上传日期</span></td>
  148.     <td Width="7%" align="center" background="Images/tn.gif"><span class="style8">管理</span></td>
  149.   </tr>
  150. <%
  151. On Error Resume Next
  152.     Set objFSO=Server.CreateObject(FsoString)
  153. If Err.Number=-2147221005 Then 
  154.     Response.Write "<Tr><Td Colspan=5 Class=Tablebody1 align='center'>非常遗憾,您的主机不支持FSO("&FsoString&"),不能使用该功能</Td></Tr>"
  155.     Err.Clear
  156.     Response.End
  157. End If
  158.     If Request("FileName")<>"" Then
  159.         If objFSO.Fileexists(Server.Mappath(""&Uploadpath&""&Request("FileName"))) Then
  160.             objFSO.Deletefile(Server.Mappath(""&Uploadpath&""&Request("FileName")))
  161.         Else
  162.             Response.Write "未找到:<U><Font Color=Red>"&Uploadpath&"/"&Request("FileName")&"</Font></U>"
  163.         End If
  164.     End If
  165.     Set Folder=objFSO.Getfolder(Server.Mappath(Uploadpath))
  166.     If Err.Number<>0 Then
  167.     Response.Write "<Tr><Td Colspan=5 Class=Tablebody1>"&Err.Description&"</Td></Tr>"
  168.     Response.End
  169.     End If
  170.     Set Num=Folder.Files
  171.     FileCount=num.count
  172.     pagecount=int(FileCount/PageSize)
  173.     Page=Request.QueryString("Page")
  174.     If Page="" Or Page<1 Then 
  175.        Page=1
  176.     Else
  177.        Page=Cint(Page)
  178.     End If 
  179. If FileCount Mod PageSize=0 Then
  180.     PageCount= FileCount  Cint(PageSize)
  181. Else
  182.     PageCount= FileCount  Cint(PageSize)+1
  183.    End If
  184.    i=0
  185.    Dim CSS
  186.    For Each FileName In folder.files
  187.       i=i+1
  188.       If i>(Page-1)*PageSize And i<=Page*PageSize Then 
  189.     If i Mod 2=0 then 
  190.             Css="table_row_1"
  191.          Else
  192.             Css="table_row_2"
  193.          End If
  194. %>
  195.   <tr bgcolor='#EBF2F9' class="<%=css%>"> 
  196.     <td height=25 align=center><%=procGetFormat(FileName.name)%></td>
  197.     <td height=25><%="<a href="&uploadpath&"/"&FileName.name&" target=_blank>"&FileName.name&"</a>"%></td>
  198.     <td height=25 align=center><%=FileName.size%> 字节</td>
  199.     <td height=25 align=center><%=FileName.datecreated%></td>
  200.     <td height=25 align=center><a href=?FileName=<%=FileName.name%>>删除</a></td>
  201.   </tr>
  202. <%
  203.       ElseIf i>Page*PageSize Then Exit For
  204.       End If
  205.    Next
  206. %>
  207.   <tr bgcolor='#EBF2F9'> 
  208.     <td height=25 colspan="5" class="table_row_1"> 
  209. <%Response.Write "共计:<b><font color=#FF0000>"&FormatNumber(folder.size/1024,2)&"</font> k</b>"%></td>
  210.   </tr>
  211.   <tr bgcolor='#D7E4F7'> 
  212.     <td height=25 colspan="5"> 
  213. <%Response.Write ShowPage(PageCount,FileCount,Page,PageSize,"?Path="&uploadpath&"&")%></td>
  214.   </tr>
  215. </table>
  216. <%
  217.     Set objFSO=Nothing
  218.     Set Folder=Nothing
  219. End Sub
  220. Function Procgetformat(Sname)
  221.     Dim I,Str
  222.     Procgetformat=0
  223.     If Instrrev(Sname,".")=0 Then Exit Function
  224.     Str=Lcase(Mid(Sname,Instrrev(Sname,".")+1))
  225.     For I=0 To Ubound(Sfor,1)
  226.         If Str=Sfor(I,0) Then 
  227.             Procgetformat=Sfor(I,1)
  228.             Exit For
  229.         End If
  230.     Next
  231. End Function
  232. %>
  233. </BODY>
  234. </HTML>