Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5994393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:48:42+00:00 2026-05-22T23:48:42+00:00

I am looking to build a directory browser in PHP. I have just started

  • 0

I am looking to build a directory browser in PHP. I have just started my code, but need someone to help me complete or modify it.

$dir = dirname(__FILE__); //path of the directory to read

$iterator = new RecursiveDirectoryIterator($dir);
foreach (new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::CHILD_FIRST) as $file) {
if (!$file->isFile()) {
echo "<a href=". $file->getPath().">" . $file->getPath() . "\</a>";
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:48:43+00:00Added an answer on May 22, 2026 at 11:48 pm

    While you develop this, its important to recognize that you are dealing with two different directory paths. One path is URL based, the other is Document based. The path / would take you to the root of your site where C:\some path\www\ would also take you there. Both of these reference the same location, using different means.

    With that said, you’re going to have to use URL based paths the navigate your interface (unless you don’t care about exposing your document path – SECURITY RISK), but the code needs to take what you’ve clicked and convert it to Document based paths. Here are some PHP functions which might help.

    __FILE__ - gives you the document path to the current PHP file
    __DIR__ or dirname(__FILE__) - gives you the document path to the folder the current file is at    
    getcwd() - gets the current working directory
    

    Also, instead of having the link go to the file path, have it post the file path and reload the page based on the posted data.

    <form name='myform' method='post'>
        <a href='folderA' onclick="document.myform.path.value=this.getAttribute('href'); document.myform.submit(); return false;">Folder A</a>
        <a href='folderB' onclick="document.myform.path.value=this.getAttribute('href'); document.myform.submit(); return false;">Folder B</a>
        <input type='hidden' name='path' value='' />
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im looking to build a thread manager for an application. I have already started
I'm looking to build a quick link directory access widget. e.g. (option 1) 0-9
I'm looking for the good way to add the build directory (which is different
i am looking to build a php function which will list all folders and
I am querying Active Directory via LDAP (from Java and PHP) to build a
gcc 4.4.2 cmake 2.6 I have just started using cmake. Coming from writing my
I'm looking for my build to delete the contents of a directory without touching
But I'm looking to install freetype, libjpeg, PIL build to add image processing to
We looking to build an application to maintain meeting minutes and similar stuff using
I'm looking to build an reusable control or custom helper for my MVC project.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.