...

View Full Version : How to make links using folder content?



Bengal313
12-12-2003, 08:53 PM
I have a php page that takes in a list of files (image files) from a directory and lists them. I wanted to know is there a way for me to create links using this list? Here is my code.


<?php
$dir = "testimages/";

// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
print "$file";
print "<br>";
}
closedir($dh);
}
}
?>

Nightfire
12-12-2003, 09:11 PM
Try changing


print "$file";

to


print "<a href=\"" . $file . "\">" . $file . "</a>";

Bengal313
12-12-2003, 09:17 PM
Thank you very much for that fast response! One currently I am accessing a folder that is in a sub directory, "/testimages". How would I access a folder that is on the same server (SUSE) but is four levels above the php page directory? I tried using ../, but didn't work.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum