LOGO OA教程 ERP教程 模切知识交流 PMS教程 CRM教程 开发文档 其他文档  
 
网站管理员

[点晴永久免费OA]ASP实现类似于资源管理器的目录生成和浏览下载文件功能

admin
2022年6月21日 9:8 本文热度 515
<!---将此文件存为folder_list.asp看看效果就知道了加上权限就可以方便自己了--->
<%
'const_domain_name为域名最后不要加斜杠
const const_domain_name="http://localhost"
%>

<style>
b,img,a{line-height:150%;text-decoration:none;color:#0000cc;}
span{font-size:12pt;}
</style>

<%
'------------------------------------------------显示当前目录下的子目录和文件
sub list
Dim fso, f, f1, fc, s
Set fso = createObject("scripting.FileSystemObject")
Set f = fso.GetFolder(server.MapPath("."))
set fs=f.SubFolders
Set fc =f.Files
For Each fss in fs
dim folder_name
folder_name=fss.name
%>
<a href="folder_list.asp?act=list_cur&cur_path=<%=fss%>"><span style="font-family:wingdings">0</span><%=folder_name%></a><br>
<%
Next
For Each f1 in fc
dim filename
filename=f1.name
%>
<a href="<%=p2v_path(f1)%>"><span style="font-family:wingdings 2">/</span><%=filename%></a><br>
<%
Next
set fso=nothing
end sub
%>

<%
'------------------------------------------------显示指定路径下的目录和文件
sub list_cur
Dim fso, f, f1, fc, s
Set fso = createObject("scripting.FileSystemObject")
Set f = fso.GetFolder(request("cur_path"))
set fs=f.SubFolders
Set fc =f.Files
For Each fss in fs
dim folder_name
folder_name=fss.name
%>
<a href="folder_list.asp?act=list_cur&cur_path=<%=fss%>"><span style="font-family:wingdings">0</span><%=folder_name%></a><br>
<%
Next

For Each f1 in fc
dim filename
filename=f1.name
%>
<a href="<%=p2v_path(f1)%>"><span style="font-family:wingdings 2">/</span><%=filename%></a><br>
<%
Next
set fso=nothing
end sub
%>

<%
'------------------------------------------------显示上级目录的子目录和子文件
sub list_parent
on error resume next
Dim fso, f, f1, fc, s
Set fso = createObject("scripting.FileSystemObject")
Set f = fso.GetFolder(display_cur_path)
set fs=f.SubFolders
Set fc =f.Files
For Each fss in fs
dim folder_name
folder_name=fss.name
%>
<a href="folder_list.asp?act=list_cur&cur_path=<%=fss%>"><span style="font-family:wingdings">0</span><%=folder_name%></a><br>
<%
Next

For Each f1 in fc
dim filename
filename=f1.name
%>
<a href="<%=p2v_path(f1)%>"><span style="font-family:wingdings 2">/</span><%=filename%></a><br>
<%
Next
set fso=nothing
on error goto 0
end sub

'---------------------------------------------得到上级目录的路径
function get_parent_folder()
on error resume next
str=display_cur_path
str_find="\"
str_int=InStrRev (str,str_find)-1 '得到上一级目录的路径
get_parent_folder=mid(str,1,str_int)
err.clear
end function


'-----------------------------------------------将文件路径转为www发布的路径这样就可以下载了
function p2v_path(p_path)
'p_path为硬盘上的物理路径
dim host
host=lcase(server.MapPath("\"))
p_path=lcase(p_path)
p2v_path=replace(p_path,host,const_domain_name)
end function

'-----------------------------------------------显示当前所在的路径
function display_cur_path()
cur_path=request("cur_path")
if cur_path="" then
display_cur_path=server.MapPath(".")
else
display_cur_path=cur_path
end if
set fso=nothing
end function

sub main
%>
<a href="folder_list.asp?act=list_parent&cur_path=<%=get_parent_folder%>">向上</a> <b><a href="javascript:void(null)"><%=display_cur_path%></a></B><p>
<%
select case request("act")
case "list_parent"
list_parent
case "list_cur"
list_cur
case else
list
end select
end sub

call main
%>

该文章在 2022/6/21 9:08:42 编辑过
关键字查询
相关文章
正在查询...
点晴ERP是一款针对中小制造业的专业生产管理软件系统,系统成熟度和易用性得到了国内大量中小企业的青睐。
点晴PMS码头管理系统主要针对港口码头集装箱与散货日常运作、调度、堆场、车队、财务费用、相关报表等业务管理,结合码头的业务特点,围绕调度、堆场作业而开发的。集技术的先进性、管理的有效性于一体,是物流码头及其他港口类企业的高效ERP管理信息系统。
点晴WMS仓储管理系统提供了货物产品管理,销售管理,采购管理,仓储管理,仓库管理,保质期管理,货位管理,库位管理,生产管理,WMS管理系统,标签打印,条形码,二维码管理,批号管理软件。
点晴免费OA是一款软件和通用服务都免费,不限功能、不限时间、不限用户的免费OA协同办公管理系统。
Copyright 2010-2024 ClickSun All Rights Reserved