Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hello!
I am currently in the process of building a web site for the class that I teach. Throughout the course, I will be posting numerous documents for my students to download, and I am looking for a javascript or related script that will automatically keep a listing of the files in a certain directory on the site.
Basically, when a student visits the page, I want the script to automatically obtain a listing of the files in the specified directory so that they can click on a certain file and download it. With the vast number of documents that I will be adding, it would be very time consuming to have to go in and create a hyperlink to each document that I upload.
Thanks in advance for your help!
Best Regards,Jamie Rhine

Javascript is unable to do this. You need a server-side scripting language to open the directory, read the files in it, and output the appropriate hyperlinks...Here is the meat of one in perl, which is one of the more popular server side languages:
#!/usr/bin/perl
print<<EndHTML;
<HTML>
<HEAD><TITLE>mypage</TITLE></HEAD>
<BODY>
EndHTML
$mydir="../mydir/assignments/";
opendir(DIR,$mydir);
@files=readdir(DIR);
foreach $file (@files)
{
if (-f "$mydir$file")
{
print "<A href=\"$mydir$myfile\">click here</A><BR>\n";
}
}
print "</BODY></HTML>";Copy and paste the above into a text file, make the directory modifications and add any text you want, name it something.pl, upload it to the server, chmod 755 it (via your ftp program), and then go to yourserver/something.pl to test it.
The first line of the program is supposed to give the directory that perl is in...This depends on your server so if you don't know it, contact somebody in IT to find out. Then again, this post could be a huge waste of time if your school's server doesn't have perl.
Good luck,
-SN

![]() |
polygon shaped forms in v...
|
Oracle manual start
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |