Jump to content

is_dir always returns false


Recommended Posts

I am trying to adapt an old peice of code that I havent looked at in over a year, so forgive me for being a bit rusty. The problem is that is_dir is returning false on everything.

 

$path=$_GET['path'];

$localpath = "/home/photos" . $path;



$dir_handle = opendir($localpath) or die("Error");



echo "<title>Photos (and other assorted files)</title>

</head>

<body>Directory Listing of: <form action='showfiles.php' method='GET'><input type='text' name='path' value='$path'><input type='submit' value='Go'></form><br/>";



while ($file = readdir($dir_handle)) 

{

if(substr($file,0,1)!="."){

	if(is_dir($file)){

 		echo"<a href='showfiles.php?path=$path/$file'>$file</a>";

	}else{
		echo"$file";
	}

	echo"<br/>";

}

}



//closing the directory

closedir($dir_handle);

 

Is the script which is running on a private Linux server that is running PHP Version 5.1.2 with safe mode off. The problem is still present when I change the local path to being inside /var/www (where the script is running from)

Link to comment
https://forums.phpfreaks.com/topic/46054-is_dir-always-returns-false/
Share on other sites

Well I tried it and got an error to the effect of that directory doesn't exist, I guessed that was what was happening and changed it to

wrong = $localpath = "photos/" . $path;

as the script is running from /var/www/private/ftp and it still finds files indicating that it is indeed using the relitive path

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.