Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
pisoj1 opened this issue Sep 22, 2016 · 5 comments
Closed

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

pisoj1 opened this issue Sep 22, 2016 · 5 comments

Comments

@pisoj1
Copy link

pisoj1 commented Sep 22, 2016

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
Copy link
Owner

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
Copy link

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
Copy link

coolshrimp commented Feb 10, 2017

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
Copy link
Owner

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

@Wolfenk
Copy link

Wolfenk commented Apr 20, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants