Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    1,137
    Thanks
    0
    Thanked 0 Times in 0 Posts

    list and link files

    how would i using ASP be able to list files in a directory on a server (the folders location is in a textbox) and then have ASP list and link all the files in that folder.

    thanks in advance

    scroots
    Spammers next time you spam me consider the implications:
    (1) that you will be persuaded by me(in a legitimate mannor)
    (2)It is worthless to you, when i have finished

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Zwolle, The Netherlands
    Posts
    1,120
    Thanks
    2
    Thanked 31 Times in 31 Posts
    <%@ LANGUAGE="JSCRIPT" %>
    <%
    var directory = "" + Request.Form("directory");
    if (directory == "undefined"){
    directory = "";
    }
    %>
    <html>
    <head><title>List and link</title></head>
    <form method="POST" action="<%=Request.ServerVariables("SCRIPT_NAME")%>">
    <table>
    <tr>
    <td>
    Directory:
    <input name="directory" type="TEXT" value="<% = directory %>" size="50">
    </td>
    <td>
    <input type="SUBMIT" value="Open">
    </td>
    </tr>
    </table>
    </form>

    <%
    if (directory != ""){
    var fileobject = Server.CreateObject("Scripting.FileSystemObject");
    if ( fileobject.FolderExists(directory)){
    var folder = fileobject.GetFolder(directory);
    var filelist = new Enumerator(folder.Files);

    for ( filelist.moveFirst() ; !filelist.atEnd() ; filelist.moveNext()) {
    var file = filelist.item();
    Response.write ("<a href='" + file.Path + "'>" + file.Name + "</a><br>\n");
    }
    }
    }
    %>
    </body>
    </html>

    put this in a file, like list.asp. put the file in a folder under your website. open it, fill in a directory, click open and voila

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    1,137
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you so much it will save me lots of time hand coding it all.

    scroots
    Spammers next time you spam me consider the implications:
    (1) that you will be persuaded by me(in a legitimate mannor)
    (2)It is worthless to you, when i have finished


  •  

    Posting Permissions

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