Jump to content

I can read files - but what about folders?


Wayneio

Recommended Posts

Hi, I have coded a site, whereby users can log in, and depending on their group, view all files within their group directory:

		if ($handle = opendir("storage/Admin/$group")) {
		while (false !== ($file = readdir($handle))) {
        if ($file != "." && $file != "..") {
            echo "<a target=\"_blank\" href=\"storage/Admin/$group/$file\">$file</a> <br />";
        }
		}
	closedir($handle);
	}

 

In this example, a user can click on their file, and it will let them download it, but if there is a folder (directory) in there, once clicked on, it will open a  index of the directory.

 

Is there a way instead, to let it open a custom page and list the files within it there?

Link to comment
Share on other sites

perhaps create a file in the subfolder like this http://www.liamdelahunty.com/tips/php_list_a_directory.php and simply EXCLUDE it when displaying

 

Thanks, think I understand this. (Quite a PHP Noob atm) Would there be an easy way to change that code, so that instead of just excluding the directory, it makes it a link to only display files then within that directory?

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.