PDA

View Full Version : downloadable file directories


dan9d9
08-31-2010, 11:11 PM
Is it possible to use dreamweaver to make pages that have lists of downloadable files inside of them by linking to directories that the files are placed in, instead of linking each file individually?
I have so many files that it would take too long to do individually.

edbr
09-01-2010, 01:47 AM
some servers disable the ability to see the contents of a directory, but in anycase it would look better if you used a php files as index php. this code should work insert the snippet where you want the list to appear
<?php
// open the current directory by opendir
$handle=opendir(".");

while (($file = readdir($handle))!==false) {
echo "$file <br>";
}

closedir($handle);

?>

edbr
09-01-2010, 02:02 AM
or better still with links to the files try this

//top of the page befor doctype
<?php
$dirname = ".";
$dir = opendir($dirname);
?>

//in the body

<?php
while(false != ($file = readdir($dir)))
{
if(($file != ".") and ($file != ".."))
{


echo("<a href='$file'>$file</a> <br />");
}
}
?>

dan9d9
09-01-2010, 05:20 AM
Thanks. That helps a lot.