![]() |
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 |
<%@ 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 |
Thank you so much it will save me lots of time hand coding it all.
scroots |
| All times are GMT +1. The time now is 07:30 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.