i'm using elfinder and i want to set path with php var (from my db connection)
here the array from my connector
include_once('../../include/header.php');
$CustomerUniqueCode=$InfoG->customer_unique_secure_code;
error_reporting(0); // Set E_ALL for debuging
require './autoload.php';
// ===============================================
function access($attr, $path, $data, $volume) {
return strpos(basename($path), '.') === 0 // if file/folder begins with '.' (dot)
? !($attr == 'read' || $attr == 'write') // set read+write to false, other (locked+hidden) set to true
: null; // else elFinder decide it itself
}
$opts = array(
//'debug' => true,
'roots' => array(
array(
'driver' => 'LocalFileSystem', // driver for accessing file system (REQUIRED)
'path' => '../../folder/customer/'.$CustomerUniqueCode.'/files/', // path to files (REQUIRED)
'URL' => dirname($_SERVER['PHP_SELF']) . '../../folder/customer/'.$CustomerUniqueCode.'/files/', // URL to files (REQUIRED)
'tmbPath' => '../files/thumbnails/',
'tmbURL' => dirname($_SERVER['PHP_SELF']) . '/../files/thumbnails',
'uploadDeny' => array('all'), // All Mimetypes not allowed to upload
'uploadAllow' => array('image', 'text/plain'),// Mimetype `image` and `text/plain` allowed to upload
'uploadOrder' => array('deny', 'allow'), // allowed Mimetype `image` and `text/plain` only
'accessControl' => 'access' // disable and hide dot starting files (OPTIONAL)
)
)
);
// run elFinder
$connector = new elFinderConnector(new elFinder($opts));
$connector->run();
The error message is :
Invalid backend configuration.
Readable volumes not available.
display_file.php including elfinder.php
Here the server organisation
Someone can help me ?
Related
In one of my Codeigniter v3.1.3 project, i have used 'KCFinder' in CKEditor for uploading images to the server. The directory structure of my localhost version of the project is:
localhost/project_ci
--application
--assets
----admin
------ckeditor
------kcfinder
--system
--index.php
Initially i was having difficulty integrating KCFinder with CKEditor but after searching the internet, i came across a tutorial(i don't rember the url now) explaining the steps to integrate it.I followed the steps mentioned there and now it works perfectly on localhost.The step1 of the said tutorial was to change some values of index.php in the root directory as:
$system_path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'system';
$application_folder = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'application';
Now i have uploaded the above project in a Shared Hosting server.In the hosting server, the files are organized as follows:
/home/myaccount
--ci_top_secret
----application
----system
--public_html
----assets
----index.php
and the system_path values in index.php are:
$system_path = '../ci_top_secret/system';
$application_folder = '../ci_top_secret/application';
My website works well, all the CKEditor's are visible.However in the 'image properties' popup when i click the 'Browse Server' button, a blank page appear showing HTTP 500 error.Hence i am not able to upload images to the remote server.I really don't understand what is wrong.Is it because of the system_path values in the index.php.Please advise with some code.Thanks
Inside KC-Finder you will find the folder conf folder
keep these file
config.php
<?php
/** This file is part of KCFinder project
*
* #desc Base configuration file
* #package KCFinder
* #version 3.12
* #author Pavel Tzonkov <sunhater#sunhater.com>
* #copyright 2010-2014 KCFinder Project
* #license http://opensource.org/licenses/GPL-3.0 GPLv3
* #license http://opensource.org/licenses/LGPL-3.0 LGPLv3
* #link http://kcfinder.sunhater.com
*/
/* IMPORTANT!!! Do not comment or remove uncommented settings in this file
even if you are using session configuration.
See http://kcfinder.sunhater.com/install for setting descriptions */
if ($_SERVER['SERVER_NAME'] == 'localhost' || strstr($_SERVER['SERVER_NAME'], '172.16')) {
$upload_url = "upload";
$upload_dir = "";
} else if ($_SERVER['HTTP_HOST'] == "216.55.169.45") {
$upload_url = "http://216.55.169.45/~mpdriver/master/assets/admin/kcfinder/upload";
$upload_dir = "/home/mpdriver/public_html/master/assets/admin/kcfinder/upload";
} else {
$upload_url = "upload";
$upload_dir = "";
}
$_CONFIG = array(
// GENERAL SETTINGS
'disabled' => FALSE,
'uploadURL' => "upload",
'uploadDir' => "",
'theme' => "default",
'types' => array(
// (F)CKEditor types
'files' => "",
'flash' => "swf",
'images' => "*img",
// TinyMCE types
'file' => "",
'media' => "swf flv avi mpg mpeg qt mov wmv asf rm",
'image' => "*img",
),
// IMAGE SETTINGS
'imageDriversPriority' => "imagick gmagick gd",
'jpegQuality' => 90,
'thumbsDir' => ".thumbs",
'maxImageWidth' => 0,
'maxImageHeight' => 0,
'thumbWidth' => 100,
'thumbHeight' => 100,
'watermark' => "",
// DISABLE / ENABLE SETTINGS
'denyZipDownload' => false,
'denyUpdateCheck' => false,
'denyExtensionRename' => false,
// PERMISSION SETTINGS
'dirPerms' => 0755,
'filePerms' => 0644,
'access' => array(
'files' => array(
'upload' => true,
'delete' => true,
'copy' => true,
'move' => true,
'rename' => true
),
'dirs' => array(
'create' => true,
'delete' => true,
'rename' => true
)
),
'deniedExts' => "exe com msi bat cgi pl php phps phtml php3 php4 php5 php6 py pyc pyo pcgi pcgi3 pcgi4 pcgi5 pchi6",
// MISC SETTINGS
'filenameChangeChars' => array(/*
' ' => "_",
':' => "."
*/),
'dirnameChangeChars' => array(/*
' ' => "_",
':' => "."
*/),
'mime_magic' => "",
'cookieDomain' => "",
'cookiePath' => "",
'cookiePrefix' => 'KCFINDER_',
// THE FOLLOWING SETTINGS CANNOT BE OVERRIDED WITH SESSION SETTINGS
'_normalizeFilenames' => false,
'_check4htaccess' => true,
//'_tinyMCEPath' => "/tiny_mce",
'_sessionVar' => "KCFINDER",
//'_sessionLifetime' => 30,
//'_sessionDir' => "/full/directory/path",
//'_sessionDomain' => ".mysite.com",
//'_sessionPath' => "/my/path",
//'_cssMinCmd' => "java -jar /path/to/yuicompressor.jar --type css {file}",
//'_jsMinCmd' => "java -jar /path/to/yuicompressor.jar --type js {file}",
);
?>
and also check your URL Pointings also.
I'm starting to work with elFinder and I don't know why but I get this error "Unable to connect to backend.Backend not found.". The connector.php looks like this
$opts = array(
// 'debug' => true,
'roots' => array(
array(
'driver' => 'LocalFileSystem', // driver for accessing file system (REQUIRED)
'path' => '../files/', // path to files (REQUIRED)
'URL' => dirname($_SERVER['PHP_SELF']) . '/../files/', // URL to files (REQUIRED)
'uploadDeny' => array('all'), // All Mimetypes not allowed to upload
'uploadAllow' => array('image', 'text/plain'),// Mimetype `image` and `text/plain` allowed to upload
'uploadOrder' => array('deny', 'allow'), // allowed Mimetype `image` and `text/plain` only
'accessControl' => 'access' // disable and hide dot starting files (OPTIONAL)
)
)
);
And the path to the file is: myproject >> dashboard >> plugins >> elfinder . What can I do to solve the problem with backend connection?
It is HTTP error "404 Not Found". Please check your connector URL.
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;
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:
Download the pre-release 3.1 version of CKFinder from this link.
Open CKFinder connector config (config.php) and look for tempDirectory option on the bottom of the file.
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.
I am using elfinder and I have a problem. I want to get current directory in elfinder but I can not.
EDITED:
this is my connector. consist of my_function that called after upload, rename or mkdir commands and I want to get uploaded files path in specified place:
<?php
error_reporting(0); // Set E_ALL for debuging
include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderConnector.class.php';
include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinder.class.php';
include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderVolumeDriver.class.php';
include_once dirname(__FILE__).DIRECTORY_SEPARATOR.'elFinderVolumeLocalFileSystem.class.php';
function access($attr, $path, $data, $volume) {
return strpos(basename($path), '.') === 0 // if file/folder begins with '.' (dot)
? !($attr == 'read' || $attr == 'write') // set read+write to false, other (locked+hidden) set to true
: null; // else elFinder decide it itself
}
function my_function($cmd, $result, $args, $elfinder)
{
// how to get current path here?
}
$opts = array(
'bind' => array('upload rename mkdir' => 'my_function'),
// 'debug' => true,
'roots' => array(
array(
'driver' => 'LocalFileSystem', // driver for accessing file system (REQUIRED)
'path' => '../files/', // path to files (REQUIRED)
'URL' => dirname($_SERVER['PHP_SELF']) . '/../files/', // URL to files (REQUIRED)
'accessControl' => 'access' // disable and hide dot starting files (OPTIONAL)
),
)
);
// run elFinder
$connector = new elFinderConnector(new elFinder($opts));
$connector->run();
You can get items URL.
function my_function($cmd, $result, $args, $elfinder)
{
// how to get current path here?
foreach ($result['added'] as $file) {
if (!empty($file['url']) && $file['url'] != 1) {
$url = $file['url'];
}
}
}
or Make inherent class ex elFinderVolumeMyLocalFileSystem
class elFinderVolumeMyLocalFileSystem extends elFinderVolumeLocalFileSystem
{
public function decode($hash) {
return parent::decode($hash);
}
}
function my_function($cmd, $result, $args, $elfinder)
{
// how to get current path here?
foreach ($result['added'] as $file) {
if ($volume = $elfinder->getVolume($file['hash'])) {
$dir = $volume->decode($file['phash']);
}
}
}
$opts = array(
'bind' => array('upload rename mkdir' => 'my_function'),
// 'debug' => true,
'roots' => array(
array(
'driver' => 'MyLocalFileSystem', // driver for accessing file system (REQUIRED)
'path' => '../files/', // path to files (REQUIRED)
'URL' => dirname($_SERVER['PHP_SELF']) . '/../files/', // URL to files (REQUIRED)
'accessControl' => 'access' // disable and hide dot starting files (OPTIONAL)
),
)
);
I am using jQuery-File-Upload (basic version) to upload file on server using jQuery. My original image file is uploading successfully but it is not uploading the thumbnail file into thumbnail folder.
I also set the write permission on this folder. But same code on my localhost is working fine, after uploading on server it is not creating thumbnail.
jQuery.each(data.result.files, function (index, file) {
alert(file.thumbnailUrl);
This alert message is showing blank on server. but on localhost showing uploaded path perfectly.
My UploadHandler.php __construct() Code is :-
function __construct($options = null, $initialize = true, $error_messages = null) {
$this->options = array(
'script_url' => $this->get_full_url().'/',
'upload_dir' => dirname($this->get_server_var('SCRIPT_FILENAME')).'../../../../../../temp/',
'upload_url' => $this->get_full_url().'../../../../../../temp/',
'user_dirs' => false,
'mkdir_mode' => 0755,
'param_name' => 'files',
// Set the following option to 'POST', if your server does not support
// DELETE requests. This is a parameter sent to the client:
'delete_type' => 'DELETE',
'access_control_allow_origin' => '*',
'access_control_allow_credentials' => false,
'access_control_allow_methods' => array(
'OPTIONS',
'HEAD',
'GET',
'POST',
'PUT',
'PATCH',
'DELETE'
),
'access_control_allow_headers' => array(
'Content-Type',
'Content-Range',
'Content-Disposition'
),
// Enable to provide file downloads via GET requests to the PHP script:
// 1. Set to 1 to download files via readfile method through PHP
// 2. Set to 2 to send a X-Sendfile header for lighttpd/Apache
// 3. Set to 3 to send a X-Accel-Redirect header for nginx
// If set to 2 or 3, adjust the upload_url option to the base path of
// the redirect parameter, e.g. '/files/'.
'download_via_php' => false,
// Read files in chunks to avoid memory limits when download_via_php
// is enabled, set to 0 to disable chunked reading of files:
'readfile_chunk_size' => 10 * 1024 * 1024, // 10 MiB
// Defines which files can be displayed inline when downloaded:
'inline_file_types' => '/\.(gif|jpe?g|png)$/i',
// Defines which files (based on their names) are accepted for upload:
'accept_file_types' => '/.+$/i',
// The php.ini settings upload_max_filesize and post_max_size
// take precedence over the following max_file_size setting:
'max_file_size' => null,
'min_file_size' => 1,
// The maximum number of files for the upload directory:
'max_number_of_files' => null,
// Image resolution restrictions:
'max_width' => null,
'max_height' => null,
'min_width' => 1,
'min_height' => 1,
// Set the following option to false to enable resumable uploads:
'discard_aborted_uploads' => true,
// Set to false to disable rotating images based on EXIF meta data:
'orient_image' => true,
'image_versions' => array(
// Uncomment the following version to restrict the size of
// uploaded images:
/*
'' => array(
'max_width' => 1920,
'max_height' => 1200,
'jpeg_quality' => 95
),
*/
// Uncomment the following to create medium sized images:
'medium' => array(
'max_width' => 400,
'max_height' => 400,
'jpeg_quality' => 80
),
'thumbnail' => array(
// Uncomment the following to use a defined directory for the thumbnails
// instead of a subdirectory based on the version identifier.
// Make sure that this directory doesn't allow execution of files if you
// don't pose any restrictions on the type of uploaded files, e.g. by
// copying the .htaccess file from the files directory for Apache:
//'upload_dir' => dirname($this->get_server_var('SCRIPT_FILENAME')).'../../../../../../thumbnail/',
//'upload_url' => $this->get_full_url().'../../../../../../thumbnail/',
// Uncomment the following to force the max
// dimensions and e.g. create square thumbnails:
//'crop' => true,
'max_width' => 80,
'max_height' => 80
)
)
);
if ($options) {
$this->options = array_merge($this->options, $options);
}
if ($error_messages) {
$this->error_messages = array_merge($this->error_messages, $error_messages);
}
if ($initialize) {
$this->initialize();
}
}