Skip to main content

Individual Folders for Different Users or Websites

When using a multisite CMS or app, each site has an individual set of files and images used in their page content. Therefore, it is critically important to isolate users of these websites in their own directories using a structure like this:

Path on disk

Set as dirFiles in the server config file

/var
/www
/files
/user-1
/user-2
/user-3
...

Access from web

Set as Files URL in the Dashboard or Flmngr.urlFiles in the client config file




https://example.com/files/user-1/
https://example.com/files/user-2/
https://example.com/files/user-3/
...

Note: These instructions relate to the self-hosted file manager script installation. If you use any cloud storage (Amazon S3 or Azure Blob), please refer to the instructions provided to you directly.

Client-side parameters​

There are two parameters in the Dashboard that are responsible for working with URLs:

File Manager URLURL of your PHP/Node script that processes
Parameter name: Flmngr.urlFileManager

Files URLURL prefix of the directory with static files available from web
Parameter name: Flmngr.urlFiles

When you have just one website, you can specify the parameters manually directly in the Dashboard interface. However, with multiple websites, especially as the number grows, you need to define the parameters dynamically.

The most common strategy is to have a single File Manager URL for everyone, which will serve requests from any website user and distinguish between directories on the fly according to cookies or other authentication data you use to access the backoffice of your CMS.

At the same time, each website will have a different Files URL prefix. These will be respected when the editor forms URLs for newly inserted images.

When you initialize N1ED (either as a standalone editor or as a plugin to CKEditor or TinyMCE), simply override these parameters at the start:

import Flmngr from "flmngr";

let userId = getUserId(); // your function

Flmngr.open({
apiKey: "your-n1ed-api-key",
urlFileManager: 'https://example.com/flmngr/flmngr.php',
urlFiles: 'https://example.com/files/user-' + userId,
isMultiple: false,
onFinish: (files) => {
console.log("User picked:");
console.log(files);
}
});

Backend​

When using a PHP backend, you can use this sample code to call the Flmngr server-side component:

$userId = ... // get it yourself

FlmngrServer::flmngrRequest(
array(
'dirFiles' => '/var/www/files/user-' . $userId,
)
);