Web Analytics Made Easy -
StatCounter is_dir function problem -- not identifing directories. - CodingForum

Announcement

Collapse
No announcement yet.

is_dir function problem -- not identifing directories.

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

  • is_dir function problem -- not identifing directories.

    Here is the snippet of the function im using to parse a directory for image files. The directory structure is <root>\<gallery>\<fishing_trip>\

    $inputPath is the gallery directory. When the function parses the gallery directory it finds ".." as a file and fishing_trip as a file. Shouldnt is_dir() recognized that ".." and fishing_trip are directories and not include them in the compiled array?

    This is just a basic image gallery im writing to be light weight and to learn a bit more about the file system functions. What am i doing wrong?

    Thanks!


    PHP Code:
    function buildFilenameArray($inputPath){
    if (
    is_dir($inputPath)) {
        if (
    $fileHandler opendir($inputPath)){
            while ( (
    $file readdir($fileHandler)) !== false ){
                if ( !
    is_dir($file) && $file != ".." ){
                    
    $fileArray[] = $inputPath $file;
                }        
            } 
        }    
    closedir($fileHandler);
    }        

    return 
    $fileArray;

    Edit: The reason im stripping the directories out is because the $fileArray gets passed to another function that resizes for thumbnails.

    Code:
    Warning: getimagesize(gallery/fishing_trip): failed to open stream: Permission denied in functions.php on line 33
    Last edited by mymilkexpired; Aug 3, 2005, 09:35 AM.

  • #2
    you need to feed is_dir() the full absolute path, not just the filename.

    Comment


    • #3
      Originally posted by devinemke
      you need to feed is_dir() the full absolute path, not just the filename.

      You the man

      Thanks

      Comment

      Working...
      X