# \[php\] link to file in directory

**URL:** <https://forum.kirupa.com/t/php-link-to-file-in-directory/66854>\
**Category:** programming\
**Created:** [October 10, 2004, 12:52am UTC](https://forum.kirupa.com/t/php-link-to-file-in-directory/66854 "2004-10-10T00:52:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 10, 2004, 12:52am UTC](https://forum.kirupa.com/t/php-link-to-file-in-directory/66854/1 "2004-10-10T00:52:08Z")

</div>

I’m reading a directory and am listing it’s content’s. I want each file or folder to link to eachother. As of now it does this but it go to the directory browsing.

You can see [here](http://www.digitalosophy.com/exp/) .

I want to make a details page that gives some other information. So basically I want to send a query to the details page which will then read that file?

Here’s what i got thus far

```php

<?
$current_dir = "/home/digitalo/public_html/exp/";
$dir = opendir($current_dir);

echo "Current directory you are browsing is $current_dir<br>";
echo "Directory Listing:<br><hr><br>";
while ($file = readdir($dir)){
	echo "<a href='$file'>$file</a><br>";
}

echo "<hr><br>";
closedir($dir);
?>

```
