sheepz Posted March 30, 2006 Share Posted March 30, 2006 i want to have a script that will work just like "directory browsing" i found this script on this site, i'm not sure where i found it, but it does work. the problem that i do have is when i change the $path = "/scripts/"; the folders with in that folder wont open. it gives me a "page cannot be found" but if i use $path = "./"; it works fine, the folders within that folder would open just like "directory browsing" the reason i need this to be /scripts/ is because i dont want the users to be able to access the wwwroot folder and it's contents. is there something wrong with the script that when i change the $path it wont open subfolders? if i use the "./" root folder it opens subfolders fine.[code]<html><head><title> Directory List</title></head><body><h2> Directory listing </h2><?$path = "./";$dir = opendir($path);echo "<ul>\n";while($file = readdir($dir)) { if ($file != "." && $file != ".." && $file != ".php") { echo "<li><a href = \"" .$file. "\" target = \" _blank\"> ".$file." </a></li> \n"; } }echo "</ul>\n";closedir($dir);?></body></html>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/6160-directory-listing-problem/ Share on other sites More sharing options...
shocker-z Posted March 30, 2006 Share Posted March 30, 2006 try using scripts/ instead of /scripts/ because /scripts/ points to the root of the hdd then /scripts which im guessing your looking to search a directory within the foleder your already in which is called scripts? Quote Link to comment https://forums.phpfreaks.com/topic/6160-directory-listing-problem/#findComment-22241 Share on other sites More sharing options...
sheepz Posted March 30, 2006 Author Share Posted March 30, 2006 [!--quoteo(post=359961:date=Mar 30 2006, 01:40 AM:name=shocker-z)--][div class=\'quotetop\']QUOTE(shocker-z @ Mar 30 2006, 01:40 AM) [snapback]359961[/snapback][/div][div class=\'quotemain\'][!--quotec--]try using scripts/ instead of /scripts/ because /scripts/ points to the root of the hdd then /scripts which im guessing your looking to search a directory within the foleder your already in which is called scripts?[/quote]the folder i want people to access is "c:\inetpub\wwwroot\scripts" when i put the folder path to "./" it will get me to the root directory of wwwRoot, and all the subfolders open correctly. When i put the folder path to "/wwwroot/scripts/" all the files work fine but the subfolder do not open correctly. i tried putting the path to "scripts/" but still no luck, when i click on the subfolders i get a "page cannot be displayed. thanks for the reply! =) Quote Link to comment https://forums.phpfreaks.com/topic/6160-directory-listing-problem/#findComment-22323 Share on other sites More sharing options...
shocker-z Posted March 30, 2006 Share Posted March 30, 2006 <html><head><title> Directory List</title></head><body><h2> Directory listing </h2><?$path = "../mail/";$dir = opendir($path);echo "<ul>\n";while($file = readdir($dir)) { if ($file != "." && $file != ".." && $file != ".php") { echo "<li><a href = \"" .$path.$file. "\" target = \" _blank\"> ".$file." </a></li> \n"; } }echo "</ul>\n";closedir($dir);?></body></html>Use that i added $path before the filename :) You could check to see if it's a dir and if so then change the link to ?path=$file and then it can search inside other folders instead of treating them as normal files :) Quote Link to comment https://forums.phpfreaks.com/topic/6160-directory-listing-problem/#findComment-22329 Share on other sites More sharing options...
sheepz Posted March 30, 2006 Author Share Posted March 30, 2006 you are awsome, it works exactly the way i want it to! thx a bunch! Quote Link to comment https://forums.phpfreaks.com/topic/6160-directory-listing-problem/#findComment-22484 Share on other sites More sharing options...
php_joe Posted May 20, 2006 Share Posted May 20, 2006 [!--quoteo(post=360205:date=Mar 31 2006, 07:54 AM:name=sheepz)--][div class=\'quotetop\']QUOTE(sheepz @ Mar 31 2006, 07:54 AM) [snapback]360205[/snapback][/div][div class=\'quotemain\'][!--quotec--]you are awsome, it works exactly the way i want it to! thx a bunch![/quote]Is there a way to remove the file extension when it's displayed?Maybe using [!--coloro:#3333FF--][span style=\"color:#3333FF\"][!--/coloro--]basename()[!--colorc--][/span][!--/colorc--]?Thanks!Joe Quote Link to comment https://forums.phpfreaks.com/topic/6160-directory-listing-problem/#findComment-37381 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.