Hi,
I have a bunch of uploaded files in a folder. Now I want to be able to get the names of these files that are stored in the folder using PHP so that can I create direct links to each file from my page. ie can PHP read the names of files from a folder?

Thanks,
Sean

<?php
$dir = ".";

$dh = opendir($dir);

while (($file = readdir($dh)) !== false) {
        echo "<A HREF=\"$file\">$file</A><BR>\n";
}

closedir($dh);
?>
commented: useful post +6
<?php $folder=dir("./textfile");

while($folderEntry=$folder->read())
{
      echo $folderEntry."<br>";
}

$folder->close();
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.