[點(diǎn)晴永久免費(fèi)OA]ASP實(shí)現(xiàn)類(lèi)似于資源管理器的目錄生成和瀏覽下載文件功能
<!---將此文件存為folder_list.asp看看效果就知道了加上權(quán)限就可以方便自己了--->
<%
'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>
<%
'------------------------------------------------顯示當(dāng)前目錄下的子目錄和文件
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
%>
<%
'------------------------------------------------顯示上級(jí)目錄的子目錄和子文件
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
'---------------------------------------------得到上級(jí)目錄的路徑
function get_parent_folder()
on error resume next
str=display_cur_path
str_find="\"
str_int=InStrRev (str,str_find)-1 '得到上一級(jí)目錄的路徑
get_parent_folder=mid(str,1,str_int)
err.clear
end function
'-----------------------------------------------將文件路徑轉(zhuǎn)為www發(fā)布的路徑這樣就可以下載了
function p2v_path(p_path)
'p_path為硬盤(pán)上的物理路徑
dim host
host=lcase(server.MapPath("\"))
p_path=lcase(p_path)
p2v_path=replace(p_path,host,const_domain_name)
end function
'-----------------------------------------------顯示當(dāng)前所在的路徑
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 編輯過(guò) |
關(guān)鍵字查詢(xún)
相關(guān)文章
正在查詢(xún)... |