-
Notifications
You must be signed in to change notification settings - Fork 0
How to allow users to have their own folder
- Setup
/connectors/php/filemanager.php
file to set dynamically your folder path with session var, for example.
session_start();
require_once('BaseHelper.php');
$fm = BaseHelper::getInstance();
$folderPath = '/userfiles/' . $_SESSION['userfoldername'] . '/';
$fm->setFileRoot($folderPath, true);
$fm->handleRequest();
The second argument in the getInstance()
method specifies whether to create folder if it doesn't exists
Don't forget to redefined the auth() function, see example below:
function auth() {
// You can insert your own code over here to check if the user is authorised.
if(isset($_SESSION['isAllowed'])) return true;
return false;
}
Note that if serverRoot
is set to true in "filemanager.config.json". $_SERVER['DOCUMENT_ROOT']
will be added automatically to the given var.
-
Then, open your "scripts/filemanager.config.json", and make sure the
fileRoot
is set to '/'; -
that's all!
Note that you may use baseUrl
to retrieve the right path to files, see also issue #339.
-
Go to the file where you are calling the script from and create your user session (unique id or name), and store in a session, eg. $_SESSION['userfoldername']
-
Open your connection file, for example: filemanager.config.php and find the line that looks like: $config['doc_root'] = $_SERVER['DOCUMENT_ROOT'] . 'assets/userfiles/user1'; Now, 'user1' should be flexible, so replace above line with something like the following: $config['doc_root'] = $_SERVER['DOCUMENT_ROOT'] . '/assets/userfiles/' . $_SESSION['userfoldername'];
-
Then, open your scripts/filemanager.config.js, and make sure the fileRoot looks like: var fileRoot = '/';
-
Don't forget to add _start() to filemanager.php!
-
that's all!