Jump to content

Orangeworker

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Everything posted by Orangeworker

  1. The code below does exactly what I want -- to simply display all files in folders/subfolders right in my browser. All I did was place the .php file into the folder (on my server) that I was looking to view. Then I opened the file with this path in my browser. For example, the .php file on my server was in /test/list.php The address I used in my browser to open the file was example.com/test/list.php This was painful...I hope it helps someone. Thanks to everyone for your help. <?php filesInDir('.'); function filesInDir($tdir) { $dirs = scandir($tdir); foreach($dirs as $file) { if (($file == '.')||($file == '..')) { } elseif (is_dir($tdir.'/'.$file)) { filesInDir($tdir.'/'.$file); } else { echo $tdir.'/'.$file."<br>"; } } } ?>
  2. I'm trying to open the .php file with the "example" address that I listed cause that's how I do it with other code that I've had a developer write for me. If that's incorrect, please tell me how I can execute this code.
  3. This is what I get when I list the absolute path on line $path = "example.com/test/list.php"; and I've got the list.php file (which has the code in it) in the "test" folder.
  4. Ha, can't believe I missed that. I've been working with so much code lately (mostly VBA) that I'm burnt out. Sorry! The revised code is working, but it's not showing sub-folders. It's only showing the files/folders that the .php file is in.
  5. Thanks for your response Shawn. When I run the code, this is what I get in my browser. Looks to me like the same code which you altered. If you have any other ideas, I'm totally open to it. Whatever you think will work. $path = "."; list_all_files($path); function list_all_files($path) { $handle = opendir($path); while ($file = readdir($handle)) { if($file != '.' && $file != '..') { echo $file . " "; if(is_dir($file)) { list_all_files("$path/$file"); } } } closedir($handle); }
  6. Anyone have any ideas? I'm pulling my hair out with this, been trying so much different code and can't get anything to work.
  7. I understand that this is a common task, but I can't find any code that works for me. I've done a lot of searching on php.net. I either get a blank screen or errors. The code above works for me which is why I want to see if it can be altered.
  8. I came accross this code on YouTube and it works great for listing the content of a folder that the .php file is in. However, how can I alter this code to list files of all folders and sub-folders? I thought plugging in an asterik might work on the "$path =" line, but it didn't. <?php $path = "."; $handle = opendir($path); while ($file = readdir($handle)) { echo $file . "<br>"; } closedir($handle); ?>
×
×
  • 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.