Miko Posted October 14, 2009 Share Posted October 14, 2009 Hello, I'm buidling a php scripts that dynamically get's subfolders from a specific folder. my code: <?php if(isset($button)){ $opendirdepot = opendir("C:/xampp/htdocs/arl/$depot/"); while($dirdepot = readdir($opendirdepot)){ if(is_dir($dirdepot)){ echo "Is a folder: ".$dirdepot."<br />"; }else{ echo "Is not a folder: ".$dirdepot."<br />"; } } closedir($opendirdepot); } ?> Output: Is a folder: . Is a folder: .. Is not a folder: 20091012 Is not a folder: 20091013 Is not a folder: Error_.log Is not a folder: Error_20091013.log The problem is that 20091012 and 20091013 are in fact folders. Anyone an idea? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/177662-solved-is_dir-problem/ Share on other sites More sharing options...
GKWelding Posted October 14, 2009 Share Posted October 14, 2009 Change to and it will work: <?php if(isset($button)){ $dir = "C:/xampp/htdocs/arl/$depot/"; $opendirdepot = opendir($dir); while($dirdepot = readdir($opendirdepot)){ if(is_dir($dir.$dirdepot)){ echo "Is a folder: ".$dirdepot."<br />"; }else{ echo "Is not a folder: ".$dirdepot."<br />"; } } closedir($opendirdepot); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/177662-solved-is_dir-problem/#findComment-936780 Share on other sites More sharing options...
GKWelding Posted October 14, 2009 Share Posted October 14, 2009 problem was, just for your knowledge than anything else, is that you need to provide is_dir() with the full path to the folder. Quote Link to comment https://forums.phpfreaks.com/topic/177662-solved-is_dir-problem/#findComment-936781 Share on other sites More sharing options...
Miko Posted October 14, 2009 Author Share Posted October 14, 2009 ok thanks, it works! Quote Link to comment https://forums.phpfreaks.com/topic/177662-solved-is_dir-problem/#findComment-936796 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.