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) Link to comment https://forums.phpfreaks.com/topic/46054-is_dir-always-returns-false/ 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; Link to comment https://forums.phpfreaks.com/topic/46054-is_dir-always-returns-false/#findComment-223762 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 Link to comment https://forums.phpfreaks.com/topic/46054-is_dir-always-returns-false/#findComment-223795 Share on other sites More sharing options...
jscix Posted April 7, 2007 Share Posted April 7, 2007 $localpath = "home/photos/" . $path; Link to comment https://forums.phpfreaks.com/topic/46054-is_dir-always-returns-false/#findComment-223813 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 Link to comment https://forums.phpfreaks.com/topic/46054-is_dir-always-returns-false/#findComment-224488 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; Link to comment https://forums.phpfreaks.com/topic/46054-is_dir-always-returns-false/#findComment-224510 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 Link to comment https://forums.phpfreaks.com/topic/46054-is_dir-always-returns-false/#findComment-224540 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?? Link to comment https://forums.phpfreaks.com/topic/46054-is_dir-always-returns-false/#findComment-224541 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 Link to comment https://forums.phpfreaks.com/topic/46054-is_dir-always-returns-false/#findComment-224554 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.