Index page displaying folder content

Associate
Joined
28 Apr 2004
Posts
269
Is there a way to create an index page (with customisable layout) that automaticaly lists the files contained in the same folder with a hyperlink so that people can download the file directly? The index page will update itself everytime a file is copied into the folder.
 
Last edited:
If you have php enabled on your server try this.

Code:
<?php

$dh = opendir($path);
while (($file = readdir($dh)) !== false) {
   echo "<a href='$path/$file'>$file</a><br />";
}
closedir($dh);

?>
 
It says this:

Warning: readdir(): supplied argument is not a valid Directory resource in /home/.server/username/domain.com/series/uploads/index.php on line 4

Warning: closedir(): supplied argument is not a valid Directory resource in /home/.server/username/domain.com/series/uploads/index.php on line 7

Does it mean php is not enabled?
 
No, if php wasn't enabled it would just print the php code as text. It's saying theres something wrong with the directory it's reading. Can't decipher any more than that.
 
$path hasn't been defined :p

I'd go for a .htaccess file in the directory with 'Options +Indexes' in it, which should give you the 'standard' Apache directory listing :)
 
Back
Top Bottom