You should skip . and ..
Maybe something like this?
function getall() {
$base = scandir('files/');
echo "<select>";
foreach ($base as $x) { // main loop start
if (strlen($x) > 3) {
$x = str_replace(".","",$x);
echo "<option class='folder' value='/" . $x . "/'>" . $x ."</option>\n"; // display item as option select
// I moved from here the }
$folders = scandir('files/' . $x . '/'); // scan next folder
foreach ($folders as $y) { // get files in folder
if (strlen($y) > 3) {
$y = str_replace("..","",$y);
echo "<option class='file' value='./". $x ."/" . $y . "'>" . $y . "</option>\n"; // display item as option select
}
}
}
} // to here
echo "</select>";
}
(otherwise the strlen
check is not so safe for checking this kind of things... It assumes you don't have real short named files.)