A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Counting Files In Folder

  1. #1
    An FKer
    Join Date
    Sep 2005
    Location
    Ontario
    Posts
    1,167

    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

  2. #2
    FK's Official Mac Hater jasonsplace's Avatar
    Join Date
    Mar 2002
    Location
    Provo, Utah
    Posts
    2,245
    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.

  3. #3
    An FKer
    Join Date
    Sep 2005
    Location
    Ontario
    Posts
    1,167
    Hey it works, thanks alot Jason!

    Is that possible to integrate with flash, or is it straight Php script.

  4. #4
    Senior Member
    Join Date
    Sep 2003
    Posts
    108
    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

  5. #5
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,875
    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&;
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center