Forum Moderators: coopster

Message Too Old, No Replies

downloading files from a directory

         

brancook

1:59 am on Aug 20, 2007 (gmt 0)

10+ Year Member



I have a file set up to read files that have been uploaded into a directory. I need the files available for download from another administration page, this is what I have right now:

<?php
$current_dir = '/mywebdirectory';
$dir = opendir($current_dir);

echo '<p>Dirctory Listing:</p><ul>';
while ($file = readdir($dir)) {
echo "<li>$file</li>";
}
echo '</ul>';
closedir($dir);
?>

I can read the files but I can't download them. Can anyone help me modify this code to make the files available for download.

Thanks

brancook

2:57 am on Aug 20, 2007 (gmt 0)

10+ Year Member



Never mind I got it:

echo "<a href='uploads/$file'>$file</a>"

duh, for some reason I just couldn't get the order right.