手机
当前位置:查字典教程网 >编程开发 >ASP教程 >web文件管理器的后续开发
web文件管理器的后续开发
摘要:web文件管理器的后续开发。。。选择自iuhxq的Blog关键字web文件管理器的后续开发。。。出处今天看了一下ccopus的DM45,做的...

web文件管理器的后续开发。。。选择自iuhxq的Blog

关键字web文件管理器的后续开发。。。

出处

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

代码如下:

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

<metahttp-equiv="Content-Type"content="text/html;charset=gb2312">

<styletype="text/css">

<>

</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))

Constpass=""'登陆密码

'登陆验证

Setfso=CreateObject("Scripting.FileSystemObject")

Path=Request("foldername")

IfPath=""ThenPath=server.MapPath("./")

ShowFolderList(Path)

Setfso=Nothing

'列出文件和文件夹

FunctionShowFolderList(folderspec)

temp=Request.ServerVariables("HTTP_REFERER")

temp=Left(temp,Instrrev(temp,"/"))

temp1=Len(folderspec)-Len(server.MapPath("./"))-1

Iftemp1>0Then

temp1=Right(folderspec,CInt(temp1))+""

ElseIftemp1=-1Then

temp1=""

EndIf

tempurl=temp+Replace(temp1,"","/")

uppath="./"+Replace(temp1,"","/")

upfolderspec=fso.GetParentFolderName(folderspec&"")

Setf=fso.GetFolder(folderspec)

%>

<scriptlanguage="javascript">

functionFile(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;

}

functionTree(id,name)

{

this.id=id;

this.name=name;

this.root=newArray();

this.length=0;

this.Add=function(file)

{

this.root.push(file);

this.length+=1;

}

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

{

switch(field)

{

case"Name":

returnf1.Name.toLowerCase()>f2.Name.toLowerCase()?true:false;

case"Size":

returnf1.Size>f2.Size?true:false;

case"Type":

//if(field=='???t?D')returnfalse;

returnf1.Type>f2.Type?true:false;

case"DateCreated":

returnf1.DateCreated>f2.DateCreated?true:false;

case"DateLastAccessed":

returnf1.DateLastAccessed>f2.DateLastAccessed?true:false;

case"DateLastModified":

returnf1.DateLastModified>f2.DateLastModified?true:false;

case"Attributes":

returnf1.Attributes>f2.Attributes?true:false;

default:

returnfalse;

}

}

this.sort=function(field,order)

{

//order:descasc

//field:NameSize

varlen=this.root.length;

if(len<2)return;

vartmp;

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

{

for(varj=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;

}

}

elseif(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;

}

}

}

}

}

}

functionfieldcode(field)

{

if(order=='desc')

{

order='asc';

}

else

{

order='desc';

}

tree.sort(field,order);

}

functionshow()

{

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

str='<tablewidth="100%"border="0"cellspacing="0"cellpadding="0">

<trbgcolor="#EEEEEE">

<td><divalign="center">操作<inputtype="checkbox"name="chkall"onclick=""></div></td>

<td><divalign="center"><aonclick="fieldcode('Name');show();"href=#>文件名</a></div></td>

<td><divalign="center"><aonclick="fieldcode('Size');show();"href=#>大小</a></div></td>

<td><divalign="center"><aonclick="fieldcode('Type');show();"href=#>类型</a></div></td>

<td><divalign="center"><aonclick="fieldcode('DateCreated');show();"href=#>创建时间</a></div></td>

<td><divalign="center"><aonclick="fieldcode('DateLastAccessed');show();"href=#>上次访问时间</a></div></td>

<td><divalign="center"><aonclick="fieldcode('DateLastModified');show();"href=#>上次修改时间</a></div></td>

<td><divalign="center"><aonclick="fieldcode('Attributes');show();"href=#>属性</a></div></td>

</tr>';

varf;

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

{

f=tree.root[i];

str+='<trbgcolor="#EEEEEE"onmouseover=this.bgColor='#F3F6FA';onmouseout=this.bgColor='#EEEEEE';>

<td><center><inputtype="checkbox"name="f"value="'+tree.id+""+f.Name+'"></center></td>

<td><ahref="'+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;

}

varfield='Name';

varorder='desc';

varstr;

</script>

<bodyonLoad="show()">

<formname="form1"method=postaction="">

<spanid="list"></span>

</form>

</body>

<%

Response.Write("<scriptlanguage=javascript>"&vbcrlf)

Response.Write("vartree=newTree('"&jscode(f.path)&"','"&jscode(f.name)&"');"&vbcrlf)

Setfc=f.SubFolders

ForEachf1infc

Response.Write("tree.Add(newFile('"&f1.name&"',"&f1.size&",'"&f1.Type&"','"&f1.DateCreated&"','"&f1.DateLastAccessed&"','"&f1.DateLastModified&"','"&f1.Attributes&"'));"&vbcrlf)

Next

setfc=f.Files

ForEachf1inFc

Response.Write("tree.Add(newFile('"&f1.name&"',"&f1.size&",'"&f1.Type&"','"&f1.DateCreated&"','"&f1.DateLastAccessed&"','"&f1.DateLastModified&"','"&f1.Attributes&"'));"&vbcrlf)

Next

Response.Write("</script>")

EndFunction

functionjscode(s)

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

endfunction

%>

【web文件管理器的后续开发】相关文章:

用FSO获得图片文件的信息(大小,宽,高)

ASP FSO文件处理函数大全

管理员登录

ASP中生成文本文件的两种方式

几个经典的ASP应用

用正则表达式写的HTML分离函数

ASP调用带参数存储过程的几种方式

文件的读出 编辑 管理

本人常用的分页代码

pjblog中清空引用的小程序

精品推荐
分类导航