web文件管理器的后续开发
2023-06-13 09:13:54 时间
web文件管理器的后续开发。。。 选择自 iuhxq 的 Blog
关键字 web文件管理器的后续开发。。。
出处
今天看了一下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
%>
关键字 web文件管理器的后续开发。。。
出处
今天看了一下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
%>
相关文章
- 局域网服务器传输大文件方案,局域网快速传输大文件【操作方案】
- java web文件上传——FileUpload
- 文件操作(File类等)API摘要[通俗易懂]
- 使用 rhai、handlebars、graphql 开发 Rust web 前端(3)- rhai 脚本、资源文件、环境变量等
- java中获取文件的服务器路径
- web大文件上传解决方案_java上传文件到服务器
- AI智能安防平台EasyCVR告警预案可支持播放告警录像视频及下载录像文件
- 使用Oracle exp快速备份数据库(oracleexp文件)
- 构建未来:Linux 架构的Web 开发(linux架构web)
- Linux 文件权限:读取、写入、分享(linux的读写权限)
- vs2015对revit2018二次开发之不启动Revit,读取rvt文件里墙及其属性详解编程语言
- MySQL物理文件(数据目录)体系结构详解
- 服务器用Web管理Linux服务器:轻松把握系统运维(web管理linux)
- 数据库构建Web与MySQL数据库之间的连接(web连接mysql)
- 从零开始:Linux下的Web开发之旅(linux下的web开发)
- 利用Web服务管理Redis(web服务redis)
- 服务快速部署Linux服务器,轻松架设Web服务(linux部署web)
- 文件MongoDB数据库:解压.tgz文件(mongodbtgz)
- 惊艳科技:Linux Web QQ系统的运行(linux web qq)
- 的应用Web开发中Redis的助力极大提升项目效率(web项目中redis)
- Web构建Redis连接简单而有效的实现方式(web 连接redis)
- Redis在Web开发中的光辉成就(web框架redis)
- 使用Redis提高Web性能的技巧(web中redis用法)
- Oracle Web访问企业无线界面新体验(oracle web访问)
- Oracle Web注册流程解析(oracle web注册)
- php利用iframe实现无刷新文件上传功能的代码