I'm trying to have a listbox with filename from a directory and I want to exclude listing of subdirectories wich isn't working.
I tried replacing !is_dir with is_file but doesn't work either.
<select name="Foto">
<?php
$dir="uploads/";
if (is_dir($dir)) {
$fd = @opendir($dir);
if($fd) {
while (($part = @readdir($fd)) == true) {
if ($part != "." && $part != "..") {
$file_array[]=$part;
}
}
}
for($i=0;$i<count($file_array);$i++) {
$npart=$file_array[$i];
if (!is_dir($npart)) { ?>
<option value="<?php echo $npart; ?>" <?php if ($row["Foto"] == $npart) { ?> selected <?php } ?> ><?php echo $npart; ?></option>
<?php
}
}
}
?>
</select>