real_illusions Posted November 30, 2006 Share Posted November 30, 2006 ok, i found the way to list all files in a directory by using this code:<?phpif ($handle = opendir('.')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { echo "$file\n"; } } closedir($handle);}?>Only problem is, it doesn't link to them files, how do you make it do that? I've tried a quick search on google, but i couldn't seem to find anything. I dont need anything fancy, just a nice list of the files, that link to that file, preferably in a new window. Link to comment Share on other sites More sharing options...
reportingsjr Posted November 30, 2006 Share Posted November 30, 2006 <?phpif ($handle = opendir('.')) {while (false !== ($file = readdir($handle))) {if ($file != "." && $file != "..") {echo "<a href=\".\\$file\">$file</a>\n";}}closedir($handle);}?> It looks like the dot is the directory so thats what I used. That should work anyways! Link to comment Share on other sites More sharing options...
jlhaslip Posted November 30, 2006 Share Posted November 30, 2006 <?phpif ($handle = opendir('.')) {while (false !== ($file = readdir($handle))) {if ($file != "." && $file != "..") {echo '<a href="' . $file . '"><br />';} closedir($handle);}?> Untested. Might have to play with it a bit, but that would be the approach to take. If the file is not the parent or self directory, create an anchor tag followed by an html new line. Link to comment Share on other sites More sharing options...
real_illusions Posted November 30, 2006 Author Share Posted November 30, 2006 thanks for the helpreportingsjr way seemed to work best for me:) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now