macguy Posted November 24, 2008 Share Posted November 24, 2008 You know when you go to a apache page that has no index.html file in it how it shows the contents of it instead, I was wondering if it is possable to get it to show the full path not just the file name..? Is this possible? Or is there some other way that I can do that? From: To: Thank you in advance for any help Quote Link to comment https://forums.phpfreaks.com/topic/133997-how-to-get-full-path-in-directory-view-in-www/ Share on other sites More sharing options...
JonnoTheDev Posted November 24, 2008 Share Posted November 24, 2008 Apache wont do this. The file path is at the top 'Index of /' You could write a file browser in php that will do this. Checkout the open_dir() function on php.net http://uk.php.net/manual/en/function.opendir.php Quote Link to comment https://forums.phpfreaks.com/topic/133997-how-to-get-full-path-in-directory-view-in-www/#findComment-697856 Share on other sites More sharing options...
wildteen88 Posted November 24, 2008 Share Posted November 24, 2008 Have a look in to the HeaderName directive. The index file Apache produces has many configuration options. Quote Link to comment https://forums.phpfreaks.com/topic/133997-how-to-get-full-path-in-directory-view-in-www/#findComment-697943 Share on other sites More sharing options...
macguy Posted December 2, 2008 Author Share Posted December 2, 2008 Thanks guys, i had a look at both your idea. First I had a look at the HeaderName directive, and well... kinda got lost and didn't find anything useful there. So today I had a look at open_dir() function and after trying out a bunch of code they had in the comments I finally came across one that kinda work, and will have to do for now. Here is what im doing: <? $handle = opendir("./"); while (($file = readdir($handle))!==false) { if(is_dir($file)){ if($file != "." && $file != ".."){?> <tr> <td align="center" bgcolor="FFFFFF">http://localhost:8888/test/<a href="<?= $file;?>"><?php echo ucwords($file)?></a><br></strong></td> </tr> <?php } } } closedir($handle); $handle = opendir("./"); while (($file = readdir($handle))!==false) { if(is_file($file)){ if($file != "." && $file != ".."){?> <tr> <td align="center" bgcolor="FFFFFF">http://localhost:8888/test/<a href="<?= $file?>"><?php echo ucwords($file)?></a><br></strong></td> </tr> <?php } } } closedir($handle); ?> Output: http://localhost:8888/test/Untitled Folder http://localhost:8888/test/Untitled Folder 2 http://localhost:8888/test/Untitled Folder 3 http://localhost:8888/test/Untitled Folder 4 http://localhost:8888/test/Untitled Folder 5 http://localhost:8888/test/4.php http://localhost:8888/test/Picture 1.png http://localhost:8888/test/Picture 2.png http://localhost:8888/test/Picture 3.png I have some more questions: Would it be easy to add a command or what ever to change all the spaces to a . (dot) or _ (underscore) or something like that? And is there a way for the php script to find out "http://localhost:8888/test/" by it's self... somehow? Quote Link to comment https://forums.phpfreaks.com/topic/133997-how-to-get-full-path-in-directory-view-in-www/#findComment-703783 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.