|
-
Counting Files In Folder
Hey everyone,
Im working on this website with my brother for my cousin and to save my cousin some effort, I need to be able to count the number of files that are contained in a folder.
Im pretty sure it will require Php, so if anyone know how or of any tutorials, could you please point me in the right direction?
Many thanks
-
FK's Official Mac Hater
PHP Code:
<?php
//get path of directory containing this script
$dir = $_SERVER['DOCUMENT_ROOT'].dirname($PHP_SELF);
//open a handle to the directory
$handle = opendir($dir);
//intitialize our counter
$count = 0;
//loop through the directory
while (false !== ($file = readdir($handle))) {
//evaluate each entry, removing the . & .. entries
if (is_file($file) && $file !== '.' && $file !== '..') {
$count++;
}
}
echo $count;
?>
Jason L. Wright
I'm not that hard to imitate. Just make some random negative claim at Apple or anything else for that matter and then have nothing to back it up.
-
Hey it works, thanks alot Jason!
Is that possible to integrate with flash, or is it straight Php script.
-
I was trying to find out how to count the number of files in a folder (to use it with an image/video gallery), and I found this old thread.
Anyway, I've tried that script in my server, and for some reason it doesn't seem to work.
If I place the .php file in the root dir of my server, it always returns 0, no matter the number of files in there.
Then if I try to place it inside any other subfolder, I always get this:
Code:
Warning: opendir(//imagenes): failed to open dir: No such file or directory in /home/www/hoysesale.awardspace.com/imagenes/contador.php on line 5
Warning: readdir(): supplied argument is not a valid Directory resource in /home/www/hoysesale.awardspace.com/imagenes/contador.php on line 9
0
Could anyone give me a clue of what I need to do?
Thanks in advance
Work like you don't need the money
Dance like nobody's watching
Love like you've never been hurt
**** like you're being filmed
-
Flashmatics
yeah use loadVars in flash to sendAndLoad to the php file given to u above... and echo out the variable from php as
echo &numberOfFiles=$count&;
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|