0

I am using KCfinder for a project, but I am stuck at the moment.

I want a dynamic uploadDir, for example: 'uploadURL' => $_SESSION['user_upload_dir']

However, the config file of KCfinder does not accept any global variables. I read the documentation (https://kcfinder.sunhater.com/integrate#session) but I have no idea what I have to do to get it working. (English is not my main language, so it is hard for me to understand what the documentation wants me to do)

In short I want this:

  • user logs in and gets a $_SESSION['upload_key']
  • user wants to upload an image, and since he is logged in, the upload directory will be changed into the upload_key: 'uploadURL' => /myuploadkey

The reason is because multiple members of the website need to have their own image folder.

All help is appreciated! :)

Saypontigohe
  • 311
  • 1
  • 2
  • 15

1 Answers1

0

Sorry, strangely is was way easier than the documentation explained. All I had to do was place a $_SESSION inside my website with information that overrides the config.php file:

$_SESSION['KCFINDER'] = array(
    'disabled' => false,
    'uploadURL' => $_SESSION['upload_dir'],
);

Of course, I put the neccesary protection around this code so only users logged in can use the file browser.

Saypontigohe
  • 311
  • 1
  • 2
  • 15