<%@language=vbscript codepage=936 %> <% option explicit response.buffer=true if trim(session("AdminName"))="" then response.write "对不起,此功能只有管理员才能使用。" response.end end if %> <% Const MaxPerPage=20 const SaveUpFilesPath_SoftPic="UploadSoftPic" const SaveUpFilesPath_Soft="UploadSoft" const SaveUpFilesPath="UploadThumbs" const SaveUpFilesPath2="UploadPhotos" dim strFileName dim Action dim totalPut,CurrentPage,TotalPages dim SavePath,TruePath,fso,theFolder,theFile,thisfile,FileCount,TotalSize,TotalSize_Page dim PhotoUrlID,strFileType Action=trim(Request("Action")) PhotoUrlID=trim(request("PhotoUrlID")) if PhotoUrlID="" then PhotoUrlID=0 else PhotoUrlID=Clng(PhotoUrlID) end if strFileName="Admin_PhotoSelect.asp?PhotoUrlID=" & PhotoUrlID select case PhotoUrlID case 999 SavePath = SaveUpFilesPath_SoftPic case 1000 SavePath = SaveUpFilesPath_Soft case 0 SavePath = SaveUpFilesPath case else SavePath = SaveUpFilesPath2 end select if right(SavePath,1)<>"/" then SavePath=SavePath&"/" '在目录后加(/) TruePath=Server.MapPath(SavePath) if request("page")<>"" then currentPage=cint(request("page")) else currentPage=1 end if %> 从已上传文件选择 <% If not IsObjInstalled("Scripting.FileSystemObject") Then Response.Write "你的服务器不支持 FSO(Scripting.FileSystemObject)! 不能使用本功能" Else set fso=CreateObject("Scripting.FileSystemObject") call main() end if sub main() if fso.FolderExists(TruePath)=False then response.write "找不到文件夹!可能是配置有误!" exit sub end if FileCount=0 TotalSize=0 Set theFolder=fso.GetFolder(TruePath) For Each theFile In theFolder.Files FileCount=FileCount+1 TotalSize=TotalSize+theFile.Size next if FileCount=0 then response.write "

 

 

没有找到任何文件!

" exit sub end if totalPut=FileCount if currentpage<1 then currentpage=1 end if if (currentpage-1)*MaxPerPage>totalput then if (totalPut mod MaxPerPage)=0 then currentpage= totalPut \ MaxPerPage else currentpage= totalPut \ MaxPerPage + 1 end if end if if currentPage=1 then showContent showpage2 strFileName,totalput,MaxPerPage response.write "
本页共显示 " & FileCount & " 个文件,占用 " & TotalSize_Page\1024 & " K
" else if (currentPage-1)*MaxPerPage
本页共显示 " & FileCount & " 个文件,占用 " & TotalSize_Page\1024 & " K
" else currentPage=1 showContent showpage2 strFileName,totalput,MaxPerPage response.write "
本页共显示 " & FileCount & " 个文件,占用 " & TotalSize_Page\1024 & " K
" end if end if end sub sub ShowContent() dim c FileCount=0 TotalSize_Page=0 %>
<% For Each theFile In theFolder.Files c=c+1 if FileCount>=MaxPerPage then exit for elseif c>MaxPerPage*(CurrentPage-1) then %> <% FileCount=FileCount+1 if FileCount mod 4=0 then response.write "" TotalSize_Page=TotalSize_Page+theFile.Size end if Next %>
<% strFileType=lcase(mid(theFile.Name,instrrev(theFile.Name,".")+1)) select case PhotoUrlID case 999 response.write "" case 1000 response.write "" case 0 response.write "" case 1 response.write "" case else response.write "" end select select case strFileType case "jpg","gif","bmp","png" response.write "" case "swf" response.write "" case "wmv","avi","asf","mpg" response.write "" case "rm","ra","ram" response.write "" case "rar" response.write "" case "zip" response.write "" case "exe" response.write "" case else response.write "" end select %>
文 件 名: <%=theFile.Name%>
文件大小: <%=round(theFile.size/1024) & " K"%>
文件类型: <%=theFile.type%>
修改时间: <%=theFile.DateLastModified%>
<% end sub %> <% sub showpage2(sfilename,totalnumber,maxperpage) dim n, i,strTemp if totalnumber mod maxperpage=0 then n= totalnumber \ maxperpage else n= totalnumber \ maxperpage+1 end if strTemp= "
" strTemp=strTemp & "共 " & totalnumber & " 个文件,占用 " & TotalSize\1024 & " K   " sfilename=JoinChar(sfilename) if CurrentPage<2 then strTemp=strTemp & "首页 上一页 " else strTemp=strTemp & "首页 " strTemp=strTemp & "上一页 " end if if n-currentpage<1 then strTemp=strTemp & "下一页 尾页" else strTemp=strTemp & "下一页 " strTemp=strTemp & "尾页" end if strTemp=strTemp & " 页次:" & CurrentPage & "/" & n & "页 " strTemp=strTemp & " " & maxperpage & "" & "个文件/页" strTemp=strTemp & " 转到:" strTemp=strTemp & "
" response.write strTemp end sub %>