Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-15-2002, 09:29 PM   PM User | #1
scroots
Senior Coder

 
Join Date: Jun 2002
Location: UK
Posts: 1,137
Thanks: 0
Thanked 0 Times in 0 Posts
scroots is an unknown quantity at this point
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
scroots is offline   Reply With Quote
Old 07-18-2002, 07:22 AM   PM User | #2
Roelf
Senior Coder

 
Join Date: Jun 2002
Location: Zwolle, The Netherlands
Posts: 1,110
Thanks: 2
Thanked 28 Times in 28 Posts
Roelf is on a distinguished road
<%@ 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
Roelf is offline   Reply With Quote
Old 07-18-2002, 06:09 PM   PM User | #3
scroots
Senior Coder

 
Join Date: Jun 2002
Location: UK
Posts: 1,137
Thanks: 0
Thanked 0 Times in 0 Posts
scroots is an unknown quantity at this point
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
scroots is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:29 PM.


Advertisement
Log in to turn off these ads.