Display Contents of a Folder
14
Display contents of a folder, see comments in code.
<?
if ($handle = opendir('./images')) //change to point to your directory
{
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != "..")
{
echo "<a href=http://yourdomain.com/images/$file>$file</a><br />"; //change to match your path
}
}
}
?>
Comments
Voting
Votes Up
albud
badfword
ColdKeyboard
dannyboy
DragonFever
lolfejs
mjlintz
morti
Pio
SecondV
sehrgut
shachi
Sonsam
sundaramkumar






-SV
// Change to point to your directory
$handle = dir('images/');
if ($handle)
{
while (false !== ($file = $handle->read()))
{
if (!in_array($file, array('.', '..')))
{
echo "<a href=\"http://yourdomain.com/images/$file\">$file</a><br />"; //change to match your path
}
}
}
?>
"; foreach($dir as $file){ $file = $file."
"; echo $file; } } ?>
<?
$dirScan = "./img/";
if ($dirScan) {
$dir = scandir($dirScan);
array_shift($dir);
array_shift($dir);
$count = count($dir);
echo "List of files [$count]:<br />";
foreach($dir as $file){
$file = $file."<br />";
echo $file;
}
}
?>