I'm not sure about your first question, but here's the answer to your second
<?
// replace with your directory name
if ($handle = opendir('dir_name/')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$extension = strrchr($file, ".doc"); // replace .doc with file extension
if ($extension == strtolower(".doc")) { // replace .doc with file extension
echo $file . "<br>";
}
}
}
}
closedir($handle);
?>
Cgraz