显示文件但不显示目录

so this code does what it should to list down files from a directory..but it also shows the directory..I want to remove it..is using scandir wrong?

    <ul>
<?php echo "List of files"?>
<?php
$dir = 'kcfinder/upload/files';
$files = scandir($dir);

foreach($files as $ind_file){
?>

<li><?php echo $ind_file;?> </a> | <a href="includes/delete.php?file=<?=$ind_file?>">Delete</a></li>
<?php
}
?>
</ul>

Using is_file function, you can check whether the current item is a file or not.

Try this code

if(is_file($dir . $ind_file)) {
 // You code
}

You should be using is_file() inside of your foreach statement.

Like So:

$dir = 'kcfinder/upload/files';
$files = scandir($dir);

foreach ($files as $ind_file) {
  if (is_file(__DIR__.'/'.$ind_file)) {
    ?>
    <li><?php echo $ind_file;?> </a> | <a href="includes/delete.php?file=<?=$ind_file?>">Delete</a></li>
    <?php
  }
}

use if(is_dir($ind_file)) for get directory and if (is_file($ind_file)) for files

$full_path = "kcfinder/upload/files";

if ($handle = opendir("$full_path")) 
{ 
    while (false !== ($file = readdir($handle))) 
    { 
        if(is_dir($full_path."/".$file))
        {
            if($file!='..' && $file!='.')
            {               
             //for folders  
            } 
       }else
       {
          //for files
       }
    }
} 
<ul>
<?php echo "List of files"?>
<?php
$dir = 'kcfinder/upload/files';
$files = scandir($dir);

foreach($files as $ind_file=>$afile){
  if($ind_file!=0 & $ind_file!=1){ // skip '.' and '..'
?>
<li><?php echo $afile;?> </a> | <a href="includes/delete.php?file=<?=$afile?>">Delete</a></li>
<?php
  }
}
?>
</ul>