halgatewood / file-directory-list

Free Super Clean PHP File Directory Listing Script
https://halgatewood.com/free/file-directory-list/
360 stars 151 forks source link

No way to specify what folder for the script to start in? #5

Closed pisoj1 closed 7 years ago

pisoj1 commented 7 years ago

Hi just wondering if there is a way to make this script start in a particular folder rather than the root?

I tried changing $items = scandir( dirname(FILE).'./foldername' ); but as a result I get loads of filemtime() errors.

halgatewood commented 7 years ago

It should look like this if you want to go down a level:

$items = scandir( dirname(__FILE__) . '/../foldername' );

And up a level:

$items = scandir( dirname(__FILE__) . '/foldername' );

coolshrimp commented 7 years ago

im having same problem.

works fine in same folder but not in another.

I Tried the suggested: $items = scandir( dirname(__FILE__) . '/../foldername' );

the folder and files from the other directory show up but i get errors: Warning: filesize(): stat failed Warning: filemtime(): stat failed for

http://puu.sh/tWbix/c76991b61a.png

coolshrimp commented 7 years ago

root -pdf --files ---2017 ---2016 ---Coming Soon.pdf -pages --fileviewer ---Filebrowserscript.html

this is my file layout so i used: $items = scandir( dirname(__FILE__) . '/../../pdf/files' ); and also tried with no luck: $items = scandir( dirname(dirname(dirname(__FILE__))) .'/pdf/files' );

halgatewood commented 6 years ago

@coolshrimp if your index.php file is in the root, you would want to do: $items = scandir( dirname(__FILE__) . '/pdf/files' );

Wolfenk commented 5 years ago

Correct way to do that on PHP 7: $items = scandir( dirname(__FILE__, 2) );

You can change "2" for your desired folder level. It goes one level up when you increase 1. There will be errors for "filemtime()" and "filesize()" when you change it. Don't know how to fix them.