Peuplarchie Posted February 27, 2010 Share Posted February 27, 2010 Good day to you all, is there a way to check if a specific folder contains: files, folder, both or none ? I read my folder with Glob, like my code here : <?PHP function globDir($dir) { $files = glob("$dir/*", GLOB_ONLYDIR); if(!empty($files)) { echo "<ul>\n"; foreach($files as $file) { echo "<li><b>". basename($file)."</b>\n"; globDir($file); echo "</li>\n"; } echo "</ul>\n"; } } globDir('Photos'); ?> The only thing I have really found is how to find if a specific file exists. I'm trying to find out if a specific folder contains : files, folders, both, none. It would return the appropriate word accordingly. Thanks and take care! Link to comment https://forums.phpfreaks.com/topic/193527-check-if-specific-folder-contains-files-folders-both-or-none/ Share on other sites More sharing options...
ocpaul20 Posted February 27, 2010 Share Posted February 27, 2010 I am not sure but I suspect that you probably have to access the folder to see what is in it. Search the manual and see what is there. You can use is_dir & is_file but subfolders will always contain the . & .. I think, so after that it is a matter of reading the directory contents and checking what each is. As I say, there may be a way to do what you want, but I have not used it. Link to comment https://forums.phpfreaks.com/topic/193527-check-if-specific-folder-contains-files-folders-both-or-none/#findComment-1018797 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.