0

I am using CKFinder to upload files to my site where all my users should have their own folder storing their own files in them.

My desired result is that the folder for user files uploaded will be ckfinder/userfiles/$USERNAME

I have the following information in the config.php file of CKFinder that simply is not working for me.

Help very much appreciated and needed.

$docRoot = getenv("DOCUMENT_ROOT"); 
$siteName = $_SERVER['HTTP_HOST'];
$USERNAME = $_SESSION['thisusername']; // session via main page username value
$baseUrl = 'http://' . $siteName . '/ckfinder/userfiles/';
$baseDir =  $docRoot . '/ckfinder/userfiles/';

/*=================================== Backends    =====*/
$config['backends'][] = array(
'name'         => 'default',
'adapter'      => 'local',
'baseUrl'      => "/ckfinder/userfiles/",
'root'         => $baseDir,
'chmodFiles'   => 0777,
'chmodFolders' => 0755,
'filesystemEncoding' => 'UTF-8',
);
James S. Null
  • 83
  • 2
  • 7

2 Answers2

1

you have to use the variable $USERNAMEsomewhere, else nothing will happen by itself. Most likely: 'baseUrl' => "/ckfinder/userfiles/" . $USERNAME ."/",

user5542121
  • 1,051
  • 12
  • 28
  • Not working means the files are uploaded in the root /images folder versus in the username folder. When I use $USERNAME in the baseURL setting the files upload into /ckfinder/userfiles/$USERNAME/$USERNAME/ – James S. Null Nov 23 '15 at 12:16
  • @James S. Null: It looks like the code is not complete - the `$USERNAME` variable is not used anywhere to point the user directory. http://docs.cksource.com/ckfinder3-php/howto.html#howto_private_folders – zaak Nov 25 '15 at 16:07
  • Here is my ckfinder config.php – James S. Null Nov 30 '15 at 13:01
  • the code is too long to post in comments .. how can I get ti to you? – James S. Null Nov 30 '15 at 13:03
0

I resolved this by putting into the config.php the following:

$USERNAME = $_SESSION['thisusername'];
if ($USERNAME){
    $baseUrl = 'http://www.myurl.org/ckfinder/userfiles/' . $USERNAME . '/';
    $baseDir =  $docRoot . '/ckfinder/userfiles/' . $USERNAME . '/';
}else{
    $baseUrl = 'http://www.myurl.org/images/';
    $baseDir =  $docRoot . '/images/';  
}
James S. Null
  • 83
  • 2
  • 7