adamriley Posted April 6, 2010 Share Posted April 6, 2010 Hi i found this little script and it does not seem to work i have "3" files and it outputs "0" <?php $dir_path = "/admin/images/"; $count = count(glob($dir_path . "*")); echo $count; ?> Quote Link to comment https://forums.phpfreaks.com/topic/197760-count-number-or-files-in-a-directory-script/ Share on other sites More sharing options...
JustLikeIcarus Posted April 6, 2010 Share Posted April 6, 2010 Works fine for me. I would suggest checking that the directory exists and the script can access it. Remember that path will start from system root "/" not document root. Quote Link to comment https://forums.phpfreaks.com/topic/197760-count-number-or-files-in-a-directory-script/#findComment-1037815 Share on other sites More sharing options...
adamriley Posted April 6, 2010 Author Share Posted April 6, 2010 Ok changed it a little but get ---------------------------------- Warning: Division by zero in C:\xampp\htdocs\Admin\Test.php on line 2 Warning: Division by zero in C:\xampp\htdocs\Admin\Test.php on line 2 4 ---------------------------------- Changed to ---------- <?php $dir_path = $_SERVER["DOCUMENT_ROOT"]/admin/images; $count = count(glob($dir_path . "*")); echo $count; ?> Quote Link to comment https://forums.phpfreaks.com/topic/197760-count-number-or-files-in-a-directory-script/#findComment-1037824 Share on other sites More sharing options...
Chris92 Posted April 6, 2010 Share Posted April 6, 2010 $dir_path = $_SERVER["DOCUMENT_ROOT"] ."/admin/images"; Quote Link to comment https://forums.phpfreaks.com/topic/197760-count-number-or-files-in-a-directory-script/#findComment-1037841 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.