madsporkmurderer Posted April 7, 2007 Share Posted April 7, 2007 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) Quote Link to comment Share on other sites More sharing options...
Demonic Posted April 7, 2007 Share Posted April 7, 2007 Im pretty sure you need an extra /: $localpath = "/home/photos/" . $path; Quote Link to comment Share on other sites More sharing options...
madsporkmurderer Posted April 7, 2007 Author Share Posted April 7, 2007 Right you are, that must have got deleted when I was messing around with which directory to look in. It still doesn't work with that fixed Quote Link to comment Share on other sites More sharing options...
jscix Posted April 7, 2007 Share Posted April 7, 2007 $localpath = "home/photos/" . $path; Quote Link to comment Share on other sites More sharing options...
madsporkmurderer Posted April 8, 2007 Author Share Posted April 8, 2007 As I said that problem was introduced after it had been shown to not work, I have changed where photos are anyway so that line now reads: $localpath = "/var/www/private/ftp/photos/" . $path; is_dir is still always returning false Quote Link to comment Share on other sites More sharing options...
jscix Posted April 8, 2007 Share Posted April 8, 2007 Remove the first slash wrong = $localpath = "/var/www/private/ftp/photos/" . $path; correct = $localpath = "var/www/private/ftp/photos/" . $path; Quote Link to comment Share on other sites More sharing options...
madsporkmurderer Posted April 8, 2007 Author Share Posted April 8, 2007 removing that makes it a relative path, sending it searching for /var/www/private/ftp/var/www/private/ftp/photos Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 8, 2007 Share Posted April 8, 2007 never done that to me... have you tried it and ended up with that result or is it just a guess?? Quote Link to comment Share on other sites More sharing options...
madsporkmurderer Posted April 8, 2007 Author Share Posted April 8, 2007 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.