i'm trying to get all the files and folders in a directory using PHP.
at the moment, I can only get the folders using my code.
this is my current code:
<?php
$folders = "";
if(isset($_GET['dir'])) {
$directory = $_GET['dir'];
$path = 'user_doc/'.$directory.''; // '.' for current
foreach (new DirectoryIterator($path) as $file) {
if ($file->isDot()) continue;
if ($file->isDir()) {
//print $file->getFilename() . '<br />';
//$folders .="<option>".$file->getFilename()."</option>";
$folders .="<div style=' width:90%; padding:14px; border-bottom:solid 1px #CCC;'><i style='font-size:18px;' class='fa fa-folder-open'></i>
<a class='defaults' href='folder.php?dir=".$file->getFilename()."'>".$file->getFilename()."</a></div>";
}
}
}
?>
the code above, ignores the files for some reason and it will only display the folders.
could someone please advise on this issue?
Thanks in advance.