Identifying files from directories

Hi,

The code below seems to work when I specify the root directory:
i.e.

$dir = opendir("./");

But when I specify a sub-directory,
i.e.

$dir = opendir("original_files");

the filename (named $file in the code) returns false for both is_file and is_dir regardless whether it is actually a file or a directory. Can anyone point me out where I am going wrong?

                
               <?php
        
		$dir = opendir("original_files");

		echo '<ul>';
		while ($file = readdir($dir)) {
			echo '<li>'.$file.'</li>';
			echo 'File: ';
			var_dump((is_file($file)));
			echo 'Directory: ';
			var_dump((is_dir($file)));			
		}
		echo '</ul>';

		closedir($dir);

		?>

Thanks heaps,
Global

What exactly are you trying to do? Get a directory listing? A file listing?

Incidently, ‘./’ is not the root directory. It is the current directory - the directory the initial PHP script started in. The root directory is ‘/’

Hey thanks for the quick reply.

I would like to list the contents within a directory, and be able to identify between a file and directory. i.e. I could wrap the directory filenames with an anchor tag so you could click through and have the folders open to show the contents within those.

Use the [fphp]glob[/fphp] function then. It’s quicker, easier and more powerful than the approach you’re taking. Read its manual entry, and if you have any questions post them here and I or someone else will answer.

Thanks for your help Michael will do.