3

I have a problem with the implementation of CKFinder 3. Everything works fine, except the uploading of files and images.

When I click on upload. I choose a file on my pc and then it gives me an error message called: Upload finished with errors. When I click on Details it shows: invalid file.

In my debug file it outputs this:

[02-Sep-2015 16:35:27 Europe/Berlin] PHP Notice:  Undefined index: dirname in ckfinder/core/connector/php/vendor/cksource/ckfinder/src/CKSource/CKFinder/Filesystem/File/UploadedFile.php on line 70

Can someone please help me with this?

This is my config.php code of CKFinder:

<?php

/*
 * CKFinder Configuration File
 *
 * For the official documentation visit http://docs.cksource.com/ckfinder3-php/
 */

/*============================ PHP Error Reporting ====================================*/
// http://docs.cksource.com/ckfinder3-php/debugging.html

// Production
error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT);
ini_set('display_errors', 0);

// Development
// error_reporting(E_ALL);
// ini_set('display_errors', 1);

/*============================ General Settings =======================================*/
// http://docs.cksource.com/ckfinder3-php/configuration.html

$config = array();

/*============================ Enable PHP Connector HERE ==============================*/
// http://docs.cksource.com/ckfinder3-php/configuration.html#configuration_options_authentication

$config['authentication'] = function() {
    return true;
};

/*============================ License Key ============================================*/
// http://docs.cksource.com/ckfinder3-php/configuration.html#configuration_options_licenseKey

$config['licenseName'] = '';
$config['licenseKey']  = '';

/*============================ CKFinder Internal Directory ============================*/
// http://docs.cksource.com/ckfinder3-php/configuration.html#configuration_options_privateDir

$config['privateDir'] = array(
    'backend' => 'default',
    'tags'   => '.ckfinder/tags',
    'logs'   => '.ckfinder/logs',
    'cache'  => '.ckfinder/cache',
    'thumbs' => '.ckfinder/cache/thumbs',
);

/*============================ Images and Thumbnails ==================================*/
// http://docs.cksource.com/ckfinder3-php/configuration.html#configuration_options_images

$config['images'] = array(
    'maxWidth'  => 1600,
    'maxHeight' => 1200,
    'quality'   => 80,
    'sizes' => array(
        'small'  => array('width' => 480, 'height' => 320, 'quality' => 80),
        'medium' => array('width' => 600, 'height' => 480, 'quality' => 80),
        'large'  => array('width' => 800, 'height' => 600, 'quality' => 80)
    )
);

/*=================================== Backends ========================================*/
// http://docs.cksource.com/ckfinder3-php/configuration.html#configuration_options_backends

$config['backends'][] = array(
    'name'         => 'default',
    'adapter'      => 'local',
    'baseUrl'      => '/VVBBC/assets/img/uploads/',
//  'root'         => '', // Can be used to explicitly set the CKFinder user files directory.
    // 'chmodFiles'   => 0777,
    // 'chmodFolders' => 0755,
    // 'filesystemEncoding' => 'UTF-8',
);

/*================================ Resource Types =====================================*/
// http://docs.cksource.com/ckfinder3-php/configuration.html#configuration_options_resourceTypes

$config['defaultResourceTypes'] = '';

$config['resourceTypes'][] = array(
    'name'              => 'Files', // Single quotes not allowed.
    'directory'         => 'files',
    'maxSize'           => 0,
    'allowedExtensions' => '7z,aiff,asf,avi,bmp,csv,doc,docx,fla,flv,gif,gz,gzip,jpeg,jpg,mid,mov,mp3,mp4,mpc,mpeg,mpg,ods,odt,pdf,png,ppt,pptx,pxd,qt,ram,rar,rm,rmi,rmvb,rtf,sdc,sitd,swf,sxc,sxw,tar,tgz,tif,tiff,txt,vsd,wav,wma,wmv,xls,xlsx,zip',
    'deniedExtensions'  => '',
    'backend'           => 'default'
);

$config['resourceTypes'][] = array(
    'name'              => 'Images',
    'directory'         => 'images',
    'maxSize'           => 0,
    'allowedExtensions' => 'bmp,gif,jpeg,jpg,png',
    'deniedExtensions'  => '',
    'backend'           => 'default'
);

/*================================ Access Control =====================================*/
// http://docs.cksource.com/ckfinder3-php/configuration.html#configuration_options_roleSessionVar

$config['roleSessionVar'] = 'CKFinder_UserRole';

// http://docs.cksource.com/ckfinder3-php/configuration.html#configuration_options_accessControl
$config['accessControl'][] = array(
    'role'                => '*',
    'resourceType'        => '*',
    'folder'              => '/',

    'FOLDER_VIEW'         => true,
    'FOLDER_CREATE'       => true,
    'FOLDER_RENAME'       => true,
    'FOLDER_DELETE'       => true,

    'FILE_VIEW'           => true,
    'FILE_UPLOAD'         => true,
    'FILE_RENAME'         => true,
    'FILE_DELETE'         => true,

    'IMAGE_RESIZE'        => true,
    'IMAGE_RESIZE_CUSTOM' => true
);


/*================================ Other Settings =====================================*/
// http://docs.cksource.com/ckfinder3-php/configuration.html

$config['overwriteOnUpload'] = false;
$config['checkDoubleExtension'] = true;
$config['disallowUnsafeCharacters'] = false;
$config['secureImageUploads'] = false;
$config['checkSizeAfterScaling'] = true;
$config['htmlExtensions'] = array('html', 'htm', 'xml', 'js');
$config['hideFolders'] = array('.*', 'CVS', '__thumbs');
$config['hideFiles'] = array('.*');
$config['forceAscii'] = false;
$config['xSendfile'] = false;

// http://docs.cksource.com/ckfinder3-php/configuration.html#configuration_options_debug
$config['debug'] = false;

/*==================================== Plugins ========================================*/
// http://docs.cksource.com/ckfinder3-php/configuration.html#configuration_options_plugins

$config['pluginsDirectory'] = __DIR__ . '/plugins';
$config['plugins'] = array();

/*================================ Cache settings =====================================*/
// http://docs.cksource.com/ckfinder3-php/configuration.html#configuration_options_cache

$config['cache'] = array(
    'imagePreview' => 24 * 3600,
    'thumbnails'   => 24 * 3600 * 365
);

/*============================== End of Configuration =================================*/

// Config must be returned - do not change it.
return $config;
EddieAjax
  • 33
  • 1
  • 4
  • 2
    Do you host CKFinder connector on IIS server? There was an issue with accessing the temporary directory on this configuration. – zaak Sep 02 '15 at 15:22
  • I'm using XAMPP locally, do I have to change something. I don't know much about IIS Servers etc. – EddieAjax Sep 03 '15 at 08:14
  • I've just checked a fresh installation of XAMPP 5.6.12 on Windows 7 and I couldn't reproduce this issue, everything seems to work fine. The only thing I had to do was enabling the `Fileinfo` extension (http://docs.cksource.com/ckfinder3-php/quickstart.html#quickstart_beforebegin_fileinfo). What version of XAMPP and what version of Windows do you use? – zaak Sep 03 '15 at 15:07
  • I have XAMPP 5.5.19 running on my Macbook Pro with Yosemite. I did the Fileinfo extension already, but It still didn't work. – EddieAjax Sep 04 '15 at 08:43

1 Answers1

1

I was able to reproduce this issue on OSX. There's a problem with access to the preconfigured temporary directory in this version of XAMPP. This can be altered with sys_temp_dir directive in php.ini, but can be also configured in the new version of CKFinder.

Please try following:

  1. Download the pre-release 3.1 version of CKFinder from this link.
  2. Open CKFinder connector config (config.php) and look for tempDirectory option on the bottom of the file.
  3. Replace sys_get_temp_dir() with your XAMPP temp directory path. For me it was /Applications/XAMPP/xamppfiles/temp/.

So instead:

$config['tempDirectory'] = sys_get_temp_dir();

there should be:

$config['tempDirectory'] = '/Applications/XAMPP/xamppfiles/temp/';

Configure other required CKFinder options, like authentication. Uploads should work fine now.

Another solution:

Instead of changing this on application level like described above you may also set a global sys_temp_dir directive in php.ini. To do that add a following line to /Applications/XAMPP/xamppfiles/etc/php.ini:

sys_temp_dir = "/Applications/XAMPP/xamppfiles/temp/"

Then restart Apache in XAMPP. After that the temporary directory location can be fetched with sys_get_temp_dir(), so there's no need to change tempDirectory option in CKFinder config.

zaak
  • 745
  • 7
  • 14
  • Thanks a lot! This solved the problem for me! I do have one question though: If you go online, do you have to change the tempDirectory back to sys_get_temp_dir()? – EddieAjax Sep 06 '15 at 19:18
  • It depends on what you mean by _going online_. If it's about making your machine accessible from the net, then no - the `tempDirectory` option should stay the same. If it's about deploying your app to a remote server, then yes - you will most probably need to set it back to `sys_get_temp_dir()`. I've edited my answer and added _Another solution_ describing how to set `sys_temp_dir` globally in `php.ini`. In this case you can keep using `sys_get_temp_dir()`. – zaak Sep 07 '15 at 06:56