Jump to content

How to get full path in directory view in WWW


macguy

Recommended Posts

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:

20081124-8ke5xynesbbw2cejjm62cws7f3.jpg

 

To:

20081124-tkwpb11ddpuiaxg3ys8h3sq947.jpg

 

Thank you in advance for any help :)

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

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? :)

Archived

This topic is now archived and is closed to further replies.

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