PHPackages                             jodit/connector - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. jodit/connector

ActiveLibrary[File &amp; Storage](/categories/file-storage)

jodit/connector
===============

Jodit FileBrowser and Uploader connector

3.0.117(8mo ago)3022.3k↓50%18[14 issues](https://github.com/xdan/jodit-connectors/issues)MITPHPPHP &gt;=8

Since Feb 18Pushed 8mo ago2 watchersCompare

[ Source](https://github.com/xdan/jodit-connectors)[ Packagist](https://packagist.org/packages/jodit/connector)[ RSS](/packages/jodit-connector/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (1)Versions (112)Used By (0)

Jodit FileBrowser Connector for Jodit v.3.0
===========================================

[](#jodit-filebrowser-connector-for-jodit-v30)

Official [Jodit WYSIWYG](http://xdsoft.net/jodit) PHP connector
---------------------------------------------------------------

[](#official-jodit-wysiwyg-php-connector)

[old version](https://github.com/xdan/jodit-connectors/tree/2.5.62) for Jodit 2.x

Install
-------

[](#install)

```
composer create-project --no-dev jodit/connector

```

or download [ZIP archive](https://xdsoft.net/jodit/store/connector.zip)

Configuration
-------------

[](#configuration)

Available options:

- `$config['saveSameFileNameStrategy'] = "addNumber"` - Strategy in case the uploaded file has the same name as the file on the server.
    - "addNumber" - The number "olsen.png" =&gt; "olsen(1).png" is added number to the file name, if such a file exists, it will be "olsen(2).png", etc.
    - "replace" - Just replace the file
    - "error" - Throw the error - "File already exists"
- `$config['quality'] = 90` - image quality
- `$config['datetimeFormat'] = 'd/m/Y'` - Date format
- `$config['root'] = __DIR__` - the root directory for user files
- `$config['baseurl'] = ($_SERVER['HTTPS'] ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . '/'` - Root URL for user files (exp. `http://xdsoft.net`)
- `$config['createThumb'] = true` - boolean, true - create thumbnails for previews (`true`)
- `$config['safeThumbsCountInOneTime'] = 20` - int, If the `createThumb` option is enabled, then with a large number of files in the folder, the server will noticeably slow down when generating so many previews. Therefore, at a time, only such a number of pictures are processed.
- `$config['thumbFolderName'] = '_thumbs'` - thumbnails folder
- `$config['excludeDirectoryNames'] = ['.tmb', '.quarantine'],` - exclude these folders
- `$config['extensions'] = ['jpg', 'png', 'gif', 'jpeg']` - an array of valid file extensions that are permitted to be loaded (`['jpg', 'png', 'gif', 'jpeg']`)
- `$config['maxFileSize'] = 8mb` - Maximum file size (0 - is unlimited) default 8Mb
- `$config['allowCrossOrigin'] = false` - Allow cross origin request
- `$config['allowReplaceSourceFile'] = true` - Allow replace source image on resized or croped version
- `$config['sources']` - Array of options
- `$config['accessControl']` - Array for checking allow/deny permissions [Read more](#access-control)
- `$config['defaultRole']="guest"` - Default role for [Access Control](#access-control)
- `$config['roleSessionVar']="JoditUserRole"` - The session key name that Jodit connector will use for checking the role for current user. [Read more](#access-control)

you can defined several sources, and override some options:

```
$config['sources'] = [
    'images' => [
        'root' => __DIR__ . '/images',
        'baseurl' => 'http://xdsoft.net/images',
        'maxFileSize' => '100kb',
        'createThumb' => false,
        'extensions' => ['jpg'],
    ]
];
```

How use with [Jodit](https://github.com/xdan/jodit/)
----------------------------------------------------

[](#how-use-with-jodit)

Filebrowser settings [Detailt options](https://xdsoft.net/jodit/doc/#modules-filebrowser-filebrowser)

```
new Jodit('#editor', {
    filebrowser: {
        ajax: {
            url: 'connector/index.php'
        }
    }
});
```

and uploader options [Default options](https://xdsoft.net/jodit/doc/#modules-uploader)

```
new Jodit('#editor', {
    uploader: {
        url: 'connector/index.php?action=fileUpload',
    }
});
```

### Customize config

[](#customize-config)

Change `config.php`

> Do not modify the default.config.php file, instead, override the settings in the config.php file

```
return [
    'sources' => [
        'joomla Images' => [
            'root' => JPATH_BASE.'/images/',
            'baseurl' => '/images/',
            'createThumb' => true,
            'thumbFolderName' => '_thumbs',
            'extensions' => array('jpg', 'png', 'gif', 'jpeg'),
        ],
        'joomla Media' => [
            'root' => JPATH_BASE.'/media/',
            'baseurl' => '/medias/',
            'createThumb' => false,
            'thumbFolderName' => '_thumbs',
            'extensions' => array('jpg', 'png', 'gif', 'jpeg'),
        ],
    ]
];
```

Authentication
--------------

[](#authentication)

Change `connector/checkAuthentication` in `connector/Application.php`

Like this:

```
function checkAuthentication () {
    /********************************************************************************/
    if (empty($_SESSION['filebrowser'])) {
        throw new \ErrorException('You do not have permission to view this directory', 403);
    }
    /********************************************************************************/
}
```

### Example Integrate with Joomla

[](#example-integrate-with-joomla)

Change `Application.php`

```
