I need the PHP code to list files in a directory. I have seen the code here and it works well. But what I need is the code should not only list the file also they should be able to be downloadable when user clicks on the file. The files are all text files.
Here is the code I found and works well for listing the files:
<?php
$username = Am_Lite::getInstance()->getUsername();
$directory = $username."/";
//get all text files with a .txt extension.
$texts = glob($directory . "*.txt");
//print each file name
foreach($texts as $text)
{
echo $text;
}
?>