欢迎光临
我们一直在努力

web文件管理器的后续开发。。。-ASP教程,ASP应用

建站超值云服务器,限时71元/月

今天看了一下ccopus的dm45,做的很不错,在这之前我也想做一个了,做一个跟windows资源管理器非常类似的程序。看到dm45以后觉得自己还是放弃吧,web方式的文件管理无论如何都是在权限允许内操作,而且大家实现的也都差不多,无非是在外观上,易操作上做文章,文件管理本来作用也不是很大,如果是多用户的权限比较难控制,既然别人做了,我想还是不要重复劳动的好,况且也不见得能做的好。下面的代码贴出来留个纪念,实现了文件的本地排序。但目录之间的层次还没有搞好。有兴趣的可以拿去参考,理论上应该可以实现跟windows资源管理器极类似的界面和操作方式。整个界面都采取无刷新方式。用xmlhttp来执行后台代码,用js来修改前台显示。这里体现了一种思想,希望对初学者能有个帮助。

代码如下:

<title>web文件管理器2.0版 http://asp2004.net</title>

<meta http-equiv="content-type" content="text/html; charset=gb2312">

<style type="text/css">

<!–

a {

font-size: 9pt;

color: #3300cc;

text-decoration: none;

}

body {

font-size: 9pt;

margin-left: 0px;

margin-top: 0px;

margin-right: 0px;

margin-bottom: 0px;

line-height: 20px;

background-color: #eeeeee;

}

td {

font-size: 9pt;

line-height: 20px;

}

.tx {

border-color:#000000;

border-left-width: 0px;

border-top-width: 0px;

border-right-width: 0px;

border-bottom-width: 1px;

font-size: 9pt;

background-color: #eeeeee;

}

.tx1 {

font-size: 9pt;

border: 1px solid;

border-color:#000000;

color: #000000;

}

–>

</style>

<%

版权声明:本代码仅供学习研究之用,本人不对因使用本程序而造成的任何后果负责。未经作者书面许可不得用于商业用途。

qq:103895

email:quxiaohui_0@163.com

http://asp2004.net

server.scripttimeout = 999

action = request("action")

temp = split(request.servervariables("url"), "/")

url = temp(ubound(temp))

const pass = ""登陆密码

登陆验证

set fso = createobject("scripting.filesystemobject")

path = request("foldername")

if path = "" then path = server.mappath("./")

showfolderlist(path)

set fso = nothing

列出文件和文件夹

function showfolderlist(folderspec)

temp = request.servervariables("http_referer")

temp = left(temp, instrrev(temp, "/"))

temp1 = len(folderspec) – len(server.mappath("./")) -1

if temp1>0 then

temp1 = right(folderspec, cint(temp1)) + "\"

elseif temp1 = -1 then

temp1 = ""

end if

tempurl = temp + replace(temp1, "\", "/")

uppath = "./" + replace(temp1, "\", "/")

upfolderspec = fso.getparentfoldername(folderspec&"\")

set f = fso.getfolder(folderspec)

%>

<script language="javascript">

function file(name, size, type, datecreated, datelastaccessed, datelastmodified, attributes)

{

this.name = name;

this.size = size;

this.type = type;

this.datecreated = datecreated;

this.datelastaccessed = datelastaccessed;

this.datelastmodified = datelastmodified;

this.attributes = attributes;

}

function tree(id, name)

{

this.id = id;

this.name = name;

this.root = new array();

this.length = 0;

this.add = function(file)

{

this.root.push(file);

this.length += 1;

}

this.max = function(f1, f2, field)

{

switch( field )

{

case "name":

return f1.name.tolowercase()>f2.name.tolowercase()? true:false;

case "size":

return f1.size>f2.size? true:false;

case "type":

//if (field == ???t?d) return false;

return f1.type>f2.type? true:false;

case "datecreated":

return f1.datecreated>f2.datecreated? true:false;

case "datelastaccessed":

return f1.datelastaccessed>f2.datelastaccessed? true:false;

case "datelastmodified":

return f1.datelastmodified>f2.datelastmodified? true:false;

case "attributes":

return f1.attributes>f2.attributes? true:false;

default:

return false;

}

}

this.sort=function(field, order)

{

//order:desc asc

//field:name size

var len = this.root.length;

if( len < 2 ) return;

var tmp;

for(var i=0; i<len-1; i++)

{

for(var j=i+1; j<len; j++)

{

if( order == "desc")

{

if( !this.max( this.root[i], this.root[j], field ) )

{

tmp = this.root[i];

this.root[i] = this.root[j];

this.root[j] = tmp;

}

}

else if ( order == "asc")

{

if( this.max( this.root[i], this.root[j], field ) )

{

tmp = this.root[i];

this.root[i] = this.root[j];

this.root[j] = tmp;

}

}

}

}

}

}

function fieldcode(field)

{

if (order == desc)

{

order = asc;

}

else

{

order = desc;

}

tree.sort(field, order);

}

function show()

{

//for (var i=0;i<form1.elements.length;i++){var e = form1.elements[i];if (e.type == "checkbox")e.checked = form1.chkall.checked;}

str = <table width="100%" border="0" cellspacing="0" cellpadding="0">\

<tr bgcolor="#eeeeee">\

<td><div align="center">操作<input type="checkbox" name="chkall" onclick=""></div></td>\

<td><div align="center"><a onclick="fieldcode(\name\);show();" href=#>文件名</a></div></td>\

<td><div align="center"><a onclick="fieldcode(\size\);show();" href=#>大小</a></div></td>\

<td><div align="center"><a onclick="fieldcode(\type\);show();" href=#>类型</a></div></td>\

<td><div align="center"><a onclick="fieldcode(\datecreated\);show();" href=#>创建时间</a></div></td>\

<td><div align="center"><a onclick="fieldcode(\datelastaccessed\);show();" href=#>上次访问时间</a></div></td>\

<td><div align="center"><a onclick="fieldcode(\datelastmodified\);show();" href=#>上次修改时间</a></div></td>\

<td><div align="center"><a onclick="fieldcode(\attributes\);show();" href=#>属性</a></div></td>\

</tr>;

var f;

for(i=0;i<tree.length;i++)

{

f = tree.root[i];

str += <tr bgcolor="#eeeeee" onmouseover=this.bgcolor=\#f3f6fa\; onmouseout=this.bgcolor=\#eeeeee\;>\

<td><center><input type="checkbox" name="f" value="+tree.id+"\\\\"+f.name+"></center></td>\

<td><a href="+f.url+">+f.name+</a></td>\

<td>+f.size+</td>\

<td>+f.type+</td>\

<td>+f.datecreated+</td>\

<td>+f.datelastaccessed+</td>\

<td>+f.datelastmodified+</td>\

<td>+f.attributes+</td>\

</tr>;

}

str += </table>;

eval(list).innerhtml = str;

}

var field = name;

var order = desc;

var str;

</script>

<body onload="show()">

<form name="form1" method=post action="">

<span id="list"></span>

</form>

</body>

<%

response.write("<script language=javascript>"&vbcrlf)

response.write("var tree = new tree("&jscode(f.path)&","&jscode(f.name)&");"&vbcrlf)

set fc = f.subfolders

for each f1 in fc

response.write("tree.add(new file("&f1.name&","&f1.size&","&f1.type&","&f1.datecreated&","&f1.datelastaccessed&","&f1.datelastmodified&","&f1.attributes&"));"&vbcrlf)

next

set fc = f.files

for each f1 in fc

response.write("tree.add(new file("&f1.name&","&f1.size&","&f1.type&","&f1.datecreated&","&f1.datelastaccessed&","&f1.datelastmodified&","&f1.attributes&"));"&vbcrlf)

next

response.write("</script>")

end function

function jscode(s)

jscode = replace(s,"\","\\\\")

end function

%>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » web文件管理器的后续开发。。。-ASP教程,ASP应用
分享到: 更多 (0)

相关推荐

  • 暂无文章