Web Analytics Made Easy -
StatCounter Files...... - CodingForum

Announcement

Collapse
No announcement yet.

Files......

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Files......

    Is there a way to get a list of files(a,d directories) in a specific directory.

    Suppose in directory images/ you have:
    icon.gif
    bla.jpg
    simeys/

    Is there anyway to get a list of those 3 items in php?
    I don't suffer from insanity, I enjoy every single minute of it!

  • #2
    PHP Code:
    $opdir opendir('gallery/bigpics');
    while (
    false!==($file readdir($opdir))) {
    if(
    $file!=="." && $file!=="..") {

    echo 
    'I found .......'.$file.'
    '
    ;

    }
    }
    closedir($opdir); 
    basically, open directory, read directory, test that the file found
    isn't named dot or dotdot (dot '.' is the directories name - eg a
    file telling the dir what its own name is, dotdot '..' is something to
    do with the parent directory -- or so I'm led to believe) and echo
    it, then close the directory.

    Edit: change the opendir('xxxxxxxxxxx') to target your named
    directory - you could use opendir('.') to scan the dir that the file
    is in.
    The above would show subdirectories as well as files. If you only
    wanted files....
    if(strpos($file,'.') && $file!=="." && $file!=="..")
    should do.
    ضkii
    New to the CF scene
    Last edited by ضkii; Jul 6, 2002, 09:00 AM.
    ضkii - formerly pootergeist
    teckis - take your time and it'll save you time.

    Comment

    Working...
    X