Cronthenoob Posted August 30, 2006 Share Posted August 30, 2006 Ok i've got this: <HTML> <HEAD> </HEAD> <BODY><?phpif ($handle = opendir('.')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && $file != "index.htm" && $file != "listfile.php") echo "<a href=\"$file\">$file</a><br>"; } closedir($handle);}?> </BODY></HTML> That will get all of the files in the directory and spit them out on the page.How can I exclude the file index.php from the list, and is there an easier way to do this than putting that index.php in every single folder?I also want to add a breadcrumbs navigtion at the top, and I have no idea how I would go about doing that. Link to comment Share on other sites More sharing options...
reportingsjr Posted August 30, 2006 Share Posted August 30, 2006 So you want to exclude index.php from showing or do you want it deleted or what? you if with the filenames should exclude it from echoing out so you shouldnt have a problem! Link to comment Share on other sites More sharing options...
Cronthenoob Posted August 30, 2006 Author Share Posted August 30, 2006 I figured out how to get the file to exclude itself from the list, that was pretty simple.I would really like to not have to put a copy of this file into every single folder for it to work. Thats the main problem. Link to comment Share on other sites More sharing options...
reportingsjr Posted August 30, 2006 Share Posted August 30, 2006 You shouldnt have to. I dont see why you would have to anyways. if you put in your if statement another "$file = "index.php" " it should work, so if it isnt index.php it will display. What problems are you having anyways? Link to comment Share on other sites More sharing options...
Cronthenoob Posted August 30, 2006 Author Share Posted August 30, 2006 It only works If I have the file in every directory and subdirectory.so if i have a folder called "images" with a folder called "good" and a folder called "bad" inside "images"I would have to put the file in the "images", "good", and "bad" folders in order to display everything in all of the folders.My question is:How can I make it so that I don't have to put a copy of the php file in every single folder? Link to comment Share on other sites More sharing options...
reportingsjr Posted August 30, 2006 Share Posted August 30, 2006 that is really wierd! Maybe it has something to do with it just stopping the while after it sees that the index.php didnt get put out.. Link to comment Share on other sites More sharing options...
Cronthenoob Posted August 30, 2006 Author Share Posted August 30, 2006 It only takes the files and folders from the current folder. If you click on a link to a different folder, the page comes up and says access is denied, unless of course you put the php file in the folder you are linking too. Link to comment Share on other sites More sharing options...
justsomeguy Posted August 30, 2006 Share Posted August 30, 2006 You are telling opendir to read the current folder:if ($handle = opendir('.')) {You need to use is_dir to detect if $file is a directory, and, if it is, have it link to the index page with the folder name in the querystring. Then open that folder with opendir. 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