Browsing directory using PHP
Are you looking to search a directory for a specific file, or just display contents of a directory? Then I think this snippet of code will be useful.
$searchFile = 'my_file.txt';
if ($handle = opendir('/path/to/files')) {
// looping through the files in the directory
while (false !== ($file = readdir($handle))) {
if($file == $searchFile) {
echo "found your file";
}
}
closedir($handle);
}
jon | August 20, 2011 | Comments (1)
Comments
Good job making it apepar easy.










