Jump to content

is_dir() seeing directories as files


Infected.Shadow

Recommended Posts

For some reason when this script runs, the main directory is listed correctly. All the folders are marked as directories. But when I go down to one of those directories, the directories in that folder are seen as files. Why is this happening on subfolders?

 

	case 'direc':
	$current_dir = $_GET['dir'];
	$dir = opendir($current_dir);

	echo '<strong>CURRENTLY BORWSING:</strong> '.$current_dir.'<br /><hr />';

	while($file = readdir($dir)) 
	{
		if(is_dir($file)) 
		{
			echo '[DIR] <a href="'.$_SERVER['PHP_SELF'].'?mode=direc&dir='.$file.'">'.$file.'</a><br />';
		}
	}

	$dir = opendir($current_dir);

	while($file = readdir($dir))
	{
		if(!is_dir($file))
		{
		 	$f = $file;
		 	$f = explode('.', $f);
		 	$filename = $f[0];
		 	$filetype = $f[1];
			echo '- <a href="'.$_SERVER['PHP_SELF'].'?mode=ss&filename='.$filename.'&filetype='.$filetype.'&fdir='.$current_dir.'">'.$file.'</a><br />';
		}
	}
	break;

Link to comment
https://forums.phpfreaks.com/topic/184290-is_dir-seeing-directories-as-files/
Share on other sites

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.