这个用脚本是搞不定的,否则你可以把人家全部的文件都拿走,包括配置,信件,密码文件等等,那浏览器还有什么安全可言? 谁还敢上网?

解决方案 »

  1.   

    //只有asp的
    <%
    '###########################
    ' 遍历文件及文件夹函数
    '[email protected]
    '###########################'过滤主要文件类型的扩展名不显示
    function   NameRule(Name)
    Name=replace(Name,".htm","")
    Name=replace(Name,".html","")
    Name=replace(Name,".asp","")
    Name=replace(Name,".aspx","")
    Name=replace(Name,".txt","")
    NameRule   =   Name
    end   function'获得父目录的路径
    function   getFarTherPath(paths)
    Folders=split(paths,"\")
    FolderName=Folders(Ubound(Folders))
    getFarTherPath=replace(paths,"\"&FolderName,"")
    end   function'''''''''''''''''''''''''''''''''显示文件
    function   showFiles(path)
    set   fso=server.CreateObject("scripting.filesystemobject")   
    on   error   resume   nextFolders=split(path,"\")
    FolderName=Folders(Ubound(Folders))
    RootName=replace(path,FolderName,"")set   objFolder=fso.GetFolder(RootName)
    set   objSubFolders=objFolder.Subfolders
    for   each   objSubFolder   in   objSubFolders
    if   instrRev(objSubFolder.name,FolderName)>0   then
    Response.Write   "<br>"   &   path
    set   objFiles=objSubFolder.Files
    for   each   objFile   in   objFiles
    Response.Write   "<br>---<a   href='"   &   path   &   "\"   &   objFile.name   &   "'>"
    Response.Write   NameRule(objFile.name)
    Response.Write   "</a>"   &   chr(10)
    next
    end   if
    next
    Response.Write   "<br><br>"
    set   objFolder=nothing
    set   objSubFolders=nothing
    set   fso=nothing
    end   function'''''''''''''''''''''''''''''''''显示子文件夹下文件
    function   showChildFiles(path)
    set   fso=server.CreateObject("scripting.filesystemobject")   
    on   error   resume   nextset   objFolder=fso.GetFolder(path)
    set   objSubFolders=objFolder.Subfolders
    for   each   objSubFolder   in   objSubFolders   
    if   not   instrRev(objSubFolder.name,".files")>0   then
    nowpath=path   +   "\"   +   objSubFolder.nameResponse.Write   "<br>"   &   nowpathset   objFiles=objSubFolder.Files
    for   each   objFile   in   objFiles
    Response.Write   "<br>---<a   href='"   &   nowpath   &   "\"   &   objFile.name   &   "'>"
    Response.Write   NameRule(objFile.name)
    Response.Write   "</a>"   &   chr(10)
    next
    Response.Write   "<p>"
    showChildFiles(nowpath)'递归调用end   ifnext   
    set   objFolder=nothing
    set   objSubFolders=nothing
    set   fso=nothing
    end   functionrealPath   =   trim(Request.Form("realPath"))
    if   realPath   <>   ""   then
    realPath   =   getFarTherPath(realPath)
    '遍历目录
    showFiles(realPath)
    showChildFiles(realPath)     
    else
    %>
    <br>
    请选择一个需要遍历所在目录的任意一个文件
    <form   name="frmName"   method="post"   action="showFiles.asp"   target="_self">
    <input   type="file"   name="realPath"   style="width:400">
    <input   type="submit"   name="loginbtn"   value="Submit">   
    <input   type="button"   name="cancelbtn"   value="Cancel"   onclick="top.location.reload();">
    </form>
    <%end   if%>