Jump to content

[SOLVED] is_dir() problem


Miko

Recommended Posts

Hello,

 

I'm buidling a php scripts that dynamically get's subfolders from a specific folder.

my code:

 

<?php

if(isset($button)){

	$opendirdepot = opendir("C:/xampp/htdocs/arl/$depot/");


	while($dirdepot = readdir($opendirdepot)){

		if(is_dir($dirdepot)){

			echo "Is a folder: ".$dirdepot."<br />";

		}else{

			echo "Is not a folder: ".$dirdepot."<br />";

		}

	}

	closedir($opendirdepot);

}

?>

 

Output:

 

Is a folder: .

Is a folder: ..

Is not a folder: 20091012

Is not a folder: 20091013

Is not a folder: Error_.log

Is not a folder: Error_20091013.log

 

The problem is that 20091012 and 20091013 are in fact folders.

 

Anyone an idea?

 

Thanks :)

Link to comment
https://forums.phpfreaks.com/topic/177662-solved-is_dir-problem/
Share on other sites

Change to and it will work:

 

<?php
      
   if(isset($button)){
      $dir = "C:/xampp/htdocs/arl/$depot/";

      $opendirdepot = opendir($dir);

      
      while($dirdepot = readdir($opendirdepot)){
                  
         if(is_dir($dir.$dirdepot)){
            
            echo "Is a folder: ".$dirdepot."<br />";
            
         }else{
            
            echo "Is not a folder: ".$dirdepot."<br />";
            
         }
         
      }
      
      closedir($opendirdepot);
   
   }

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.