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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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