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; ?> 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. 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; ?> 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"; 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
Archived
This topic is now archived and is closed to further replies.