Skip to content

How to allow users to have their own folder

Pavel Solomienko edited this page Feb 10, 2016 · 2 revisions

With current version

  1. Create a user.config.php file to set dynamically your folder path with session var, for example.
session_start();

$folderPath = '/assets/userfiles/' . $_SESSION['userfoldername'].'/';
$fm = new Filemanager();
$fm->setFileRoot($folderPath);

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.js. $_SERVER['DOCUMENT_ROOT'] will be added automatically to the given var.

  1. Then, open your scripts/filemanager.config.js, and make sure the fileRoot is set to '/';

  2. that's all!

Note that you may use baseUrl to retrieve the right path to files, see also issue #339.

With version <= 0.8

  1. 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']

  2. 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'];

  3. Then, open your scripts/filemanager.config.js, and make sure the fileRoot looks like: var fileRoot = '/';

  4. Don't forget to add _start() to filemanager.php!

  5. that's all!

from http://forum.filemanager.corefive.com/topic/allow-different-user-to-have-own-folder-a-simple-hack-that-works#18308000000226001