I am trying to list all the files included in folder using following php scripts:
$dir = 'd:/temp_file/voice/';
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
echo "filename: ".$file."<br />";
}
closedir($dh);
}
}
The problem is that it also shows the folder with . name which output is shown below. How can I avoid those folder.
filename: .
filename: ..
filename: _19031265739am014771957.wav
filename: _19031265758am014771957.wav
using if statement… ?
if($file != '.' && $file != '..')if you want to filter out all directories (not just . and ..):
if(is_file($dir . $file))