SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot dhantiflag's Avatar
    Join Date
    Mar 2005
    Location
    Mentor, oh
    Posts
    158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    displaying directory of a remote server

    hello, the asp file is on lets say server a0001 but the directoy that i want to display is on server a0002 now, as it is i can get anything under like a0001 to display just by the normal /folder but i tried to get it to display from a0002 by this "\\a0002\folder but that didnt work so i dun kno what else i can try or do


    here is the code im using to display right now

    Code:
    <%@ LANGUAGE="VBScript" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <title>ASP Directory Listing</title>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <link rel="stylesheet" type="text/css" href="/common/default.css" />
    </head>
    <body>
    
    <div id="demoBox">
    
    <h3>ASP Directory Listing</h3>
    
    <p>Three separate directories from the web server root are displayed below
    ("asp", "dhtml" and "js"), showing all subdirectories and files. Additionally,
    each file is displayed as a link.</p>
    
    </div>
    
    <!-- List these three folders. -->
    <ul>
    <% ListFolderContents(Server.MapPath("/tools")) %>
    <% ListFolderContents(Server.MapPath("/visios")) %>
    <% ListFolderContents(Server.MapPath("/js")) %>
    </ul>
    
    </body>
    </html>
    
    <% sub ListFolderContents(path)
    
         dim fs, folder, file, item, url
    
         set fs = CreateObject("Scripting.FileSystemObject")
         set folder = fs.GetFolder(path)
    
         Response.Write("<li><b>" & folder.Name & "</b> - " _
           & folder.Files.Count & " files, ")
         if folder.SubFolders.Count > 0 then
           Response.Write(folder.SubFolders.Count & " directories, ")
         end if
         Response.Write(Round(folder.Size / 1024) & " KB total." _
           & vbCrLf)
    
         Response.Write("<ul>" & vbCrLf)
    
         for each item in folder.SubFolders
           ListFolderContents(item.Path)
         next
    
         for each item in folder.Files
           url = MapURL(item.path)
           Response.Write("<li><a href=""" & url & """>" & item.Name & "</a> - " _
             & item.Size & " bytes, " _
             & "last modified on " & item.DateLastModified & "." _
             & "</li>" & vbCrLf)
         next
    
         Response.Write("</ul>" & vbCrLf)
    
         Response.Write("</li>" & vbCrLf)
    
       end sub
    
       function MapURL(path)
    
         dim rootPath, url
    
         rootPath = Server.MapPath("/")
         url = Right(path, Len(path) - Len(rootPath))
         MapURL = Replace(url, "\", "/")
    
       end function %>

  2. #2
    Also available in Large Si's Avatar
    Join Date
    Sep 2002
    Location
    Walsall, UK
    Posts
    1,911
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you've got permissions on server a0001 to see server a0002 then you should be able to view the files using the "\\a0002" path. If you don't have permissions and cant set them, then you may have to create an ASP file on the second server that does a local FSO and creates a variable or XML file containing the files, which you will then have to call from the first server as a HTTP request.
    Si
    Are you a Photoshop Jedi Master? Prove it!

    Is funky house your bag? You'll love this!

    Voice
    , eyes, ears, body and hands.


  3. #3
    SitePoint Zealot dhantiflag's Avatar
    Join Date
    Mar 2005
    Location
    Mentor, oh
    Posts
    158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i dont know if thats my problem because right now, the error that i get is it says invalid charectors... so i dont know if i do just 1 \a0002 then i get path no found but \\a0002 says invalid

  4. #4
    SitePoint Zealot dhantiflag's Avatar
    Join Date
    Mar 2005
    Location
    Mentor, oh
    Posts
    158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this is the error that is genrated with that //a0002



    Server.MapPath() error 'ASP 0174 : 80004005'

    Invalid Path Character(s)

    /dir.asp, line 23

    An invalid '/' or '\' was found in the Path parameter for the MapPath method.


    **ADDDED**


    this is the error with only \a0002



    Microsoft VBScript runtime error '800a004c'

    Path not found

    /dir.asp, line 36

  5. #5
    SitePoint Zealot dhantiflag's Avatar
    Join Date
    Mar 2005
    Location
    Mentor, oh
    Posts
    158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    maybe its a problem because were using Server.mappath? do i need to use a different function?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •