欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

asp+fso在线管理图片功能 原创

程序员文章站 2022-03-10 14:47:19
复制代码 代码如下:<% '--------------------------------------------- '##############20060528...
复制代码 代码如下:

<%
'---------------------------------------------
'##############20060528新增加了对端口的支持
'作者:dxy qq:461478385 email:douxy001@gmail.com
'功能完善
%>
<!--#include file="global.asp"-->
<!--#include file="session.asp"-->
<%
set myfile=server.createobject("scripting.filesystemobject")
  if request.form("action")="delall" then
     num=request.form("delfilename").count
    for x=1 to num
    thedelall=server.mappath("../upload/"&request.form("delfilename")(x))
    if myfile.fileexists(thedelall) then
    myfile.deletefile(thedelall)
    end if
    next
    end if
page=cint(request.querystring("page"))
  if page<=1 or page="" then page=1
  pagesize=25
  domain=request.servervariables("server_name")
  gfilepath=request.servervariables("path_info")
  serverport=request.servervariables("server_port")
  gfilepath=lcase(left(gfilepath,instrrev(gfilepath,"/")))
  countn=len(gfilepath)
  gfilepath=lcase(left(gfilepath,countn-1))
  gfilepath=lcase(left(gfilepath,instrrev(gfilepath,"/")))
  if serverport<>"80" then
  allpath="http://"&domain&":"&serverport&gfilepath
  else
  allpath="http://"&domain&gfilepath
  end if
filepath="../upload/"
dim fso
set fso=server.createobject("scripting.filesystemobject")
set thefolder=fso.getfolder(server.mappath(filepath))
for each ffiles in thefolder.files
filecounts=filecounts+1
filesizes=filesizes+ffiles.size
if filesizes=0 then
response.write "此文件夹下没有内容"
response.end
end if
next

%>
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>dxy文件管理器</title>
<link href="main.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript">
function checkall()
{
for (var ic=0;ic<form1.delfilename.length;ic++)
{
var e = form1.delfilename[ic];
e.checked = !e.checked;
}
}
</script>
</head>

<body style="margin:0px;">
<table width="760" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#1f429e">
  <form action="" method="post" name="form1"><tr>
    <td width="40" height="25" bgcolor="#ffffff"><div align="center">序号</div></td>
    <td width="493" height="25" bgcolor="#ffffff"><div align="center">文件名</div></td>
    <td width="100" bgcolor="#ffffff"><div align="center">文件大小</div></td>
    <td width="98" bgcolor="#ffffff"><div align="center">选择</div></td>
  </tr>
  <%
  i=0
  for each ffiles in thefolder.files
  i=i+1
  if ccount>=pagesize then
  exit for
  elseif i>pagesize*(page-1) then
  ccount=ccount+1
   %>
  <tr>
    <td height="25" nowrap="nowrap" bgcolor="#ffffff" align="center"><%=i%></td>
    <td nowrap="nowrap" bgcolor="#ffffff"><a href="<%=allpath&"upload/"&ffiles.name%>" target="_blank"><img src=<%=allpath&"upload/"&ffiles.name%> border="0" /></a></td>
    <td nowrap="nowrap" bgcolor="#ffffff"><div align="center"><%=ffiles.size%>[字节]</div></td>
    <td nowrap="nowrap" bgcolor="#ffffff">
      <div align="center">
        <input name="delfilename" type="checkbox" id="delfilename" value="<%=ffiles.name%>" />
      </div></td></tr>
  <%   
  end if
  next
  %>
  <tr>
    <td height="30" colspan="4" bgcolor="#ffffff"><div align="center"> 
      共有文件<font color="#ff0000" style="font-family:georgia, 'times new roman', times, serif"><%=filecounts%></font>个,占用空间<font color="#ff0000" style="font-family:georgia, 'times new roman', times, serif"><%=formatnumber((filesizes/1024),2)%>k</font><br />        
      <input name="dxy_foldername" type="hidden" id="dxy_foldername" value="<%=request("dxy_foldername")%>" />
      <input type="button" name="submit2" value="全选/反选" onclick="checkall()" />
         
       <input type="submit" name="submit" value="确定删除所选的文件" />
        </p>
        <input name="action" type="hidden" id="action" value="delall" />
    </div></td>
    </tr>
  </form>
</table>
<table width="760" height="21" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td bgcolor="#ffffff"><div align="center">
      <%
     if filecounts mod pagesize=0 then
      pagecount=filecounts/pagesize
      else
      pagecount=filecounts/pagesize+1
      end if
      if page>pagecount then
      page=pagecount
      else
      page=page
      end if
    for ii=1 to pagecount
  if page=ii then
    response.write "<a href=picmanage.asp?page="&ii&">[<font color=red>"&ii&"</font>]</a>  "
    else
    response.write "<a href=picmanage.asp?page="&ii&">["&ii&"]</a>  "
    end if
  next
%>
    </div></td>
  </tr>
</table>
</body>
</html>