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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.