How to change upload directory path of ckfinder in codeigniter - codeigniter

I have integrated ckfinder 3 for php and after uploading images, getting the directory of uploaded images in the root, not in my project directory but I need inside my project directory like project/upload/ckfinder/userfiles
I am trying as follows in the ckfinder/config.php file of ckfinder:
$config['backends'][] = array(
'name' => 'default',
'adapter' => 'local',
'baseUrl' => base_url().'upload/ckfinder/userfiles/',
//'root' => '', // Can be used to explicitly set the CKFinder user files directory.
'chmodFiles' => 0777,
'chmodFolders' => 0755,
'filesystemEncoding' => 'UTF-8',
);
But It is not working
Please help me. Thanks in advance

baseUrl is optional for setting the backend and root is required.
If "project" is the folder where the CodeIgniter file index.php is found then use this backend
$config['backends'][] = array(
'name' => 'default',
'adapter' => 'local',
//'baseUrl' => '',
'root' => FCPATH .'upload/ckfinder/userfiles/',
'chmodFiles' => 0755,
'chmodFolders' => 0755,
'filesystemEncoding' => 'UTF-8',
'followSymlinks' => true
);

Related

laravel : symlink storage in public not working " 404 (not found)"

when I try to visualise my picture with this basic url on google :
domain.com/storage/transports/picture.png
I get (404) not found.
(I don't have this error for a file outside the storage symlink in my tree picture and I can totaly see it without any problems, exemple :
domain.com/logo.svg
I have used php artisan storage:link to create the symlink, so far I'm abble to store the pictures exactly where I want to with that controller :
public function storeTransports(Request $request)
{
try{
session(['content'=>'content_transports']);
$request->validate([
'name' => [ 'string', 'max:255'],
'picture' => [ 'required','image','mimes:jpeg,png,jpg,gif,svg', 'max:2048']
]);
if(Transport::where('name', $request->name)->first()){
return redirect(RouteServiceProvider::HOME)->with('error_transports', 'Transport already exists');
}
else{
if($request->hasFile('picture')){
$sanitized_image_name = strtolower(preg_replace("([^A-Za-z0-9])", "", $request->name)).'_'.time();
$image_name = $sanitized_image_name.'.'.$request->picture->extension();
Transport::create([
'name' => $request->name,
'path_picture' => $image_name
]);
$request->picture->storeAs('public/transports',$image_name);
}
}
return redirect(RouteServiceProvider::HOME)->with('success_transports', 'Transport saved successfully');
} catch (\Illuminate\Database\QueryException $e){
return redirect(RouteServiceProvider::HOME)->with('error_transports',$e->errorInfo);
}
}
I can also visualize my pictures in my public folder :
i've rm rf public/storage many times already
here is my configfiles.php :
<?php
return [
'default' => env('FILESYSTEM_DISK', 'public'),
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
'throw' => false,
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
'throw' => false,
],
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => false,
],
],
'links' => [
public_path('storage') => storage_path('app/public'),
],
];
I appreciate your help, I've been looking at all the stackoverflow talking about that for the past hour.
PS: I don't use vagrant.
EDIT:
i finally fixed my issue, as Matty10209 mentoned here,
"[...]When running "php artisan storage:link", Laravel creates an absolute path for the image to your local directory. Docker does not like this and wants a relative one, so it breaks the image link and you get a 404. You have to create the symlink manually[...]"
"[...] Go to docker and the CLI of your project container (should be at the bottom). Delete the current symlink you have created with Laravel, then navigate to the path you wish to create a new one. and run
ln -s ../storage/app/public storage
[...]"

Create a thumb and original image

in my controller very simply I load an image like this:
// upload original
$path = $request->file('thumb')->store('thumbs');
However, I want to create a thumbnail of predefined size (for example 100x100), using the same name created automatically .. adding only "_thumb" to the name.
I use the library http://image.intervention.io/getting_started/introduction
You have to use following code
Adding this in header section
use ImageResize;
And in your controller use following code
$photoThumbnail = ImageResize::make($request->file('thumb'))
->resize(100, 100, function ($constraint) { $constraint->aspectRatio(); } )
->encode('jpg',100);
Storage::disk('thumbnail')->put("your_image_name", $photoThumbnail);
In your app/config folder filesystems.php add this configuration
'thumbnail' => [
'driver' => 'local',
'root' => storage_path('app/public/thumbnail'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
'permissions' => [
'file' => [
'public' => 0664,
'private' => 0600,
],
'dir' => [
'public' => 0775,
'private' => 0700,
],
],
],
You have to configure also app\config folder app.php file provider section
Intervention\Image\ImageServiceProvider::class,
and aliases section use
'ImageResize' => Intervention\Image\Facades\Image::class,
For More Details

Laravel make dynamic root at runtime in filesystem

I am trying to upload image from one server to another server. I am using laravel filesystem. I have too many folders for file uploading. I want to make root location dynamic at runtime. But i am not getting any proper solution for this problem. Can anyone help me regarding this problem.
[
'driver' => '',
'host' => '111.111.11.11',
'username' => 'root',
'password' => 'test!####!',
'visibility' => 'public',
'permPublic' => 0777,
'root' => '/var/www/html/tests',
]

Issue displaying images with Laravel file manager. Routes question

I'm messed with the paths to get UniSharp / laravel-filemanager working on the server. In local mode it works perfectly but now I'm making the change of routes for production in online mode and I am not clear at all.
The problem is that it loads the images but they are not displayed either on the page or in the filemanager itself. In filemanager, I can see a red square with a cross (as error).
Let's see if anyone knows how to write the correct routes. I have tried many things but I'm messed.
The server files scaffolding:
server_files
my_laravel_app
public_html
another_files
The config filesystem.php file in Laravel:
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('public_html'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
],
],
'links' => [
public_path('storage') => storage_path('app/public'),
],
I have, default uploading path in filemanager's lfm.php:
'disk' => 'public',
In case it helps something, this is my index.php ubicated at public_html:
if (file_exists(__DIR__.'/../my_app_laravel/storage/framework/maintenance.php')) {
require __DIR__.'/../my_app_laravel/storage/framework/maintenance.php';
}
require __DIR__.'/../my_app_laravel/vendor/autoload.php';
$app = require_once __DIR__.'/../my_app_laravel/bootstrap/app.php';
And this is ServiceProviders.php
public function register()
{
$this->app->bind('path.public', function() {
return base_path().'/public_html';
});
}
How should be the correct path in filesystem to allow filemanager can access to images and display them?
Note: the public_html folder has the symbolic link as you can see at filesystem.php.
I have checking routes and I solved temporary:
I changed:
'public' => [
'driver' => 'local',
/* this */ 'root' => storage_path('app/public'),
/* this */ 'url' => env('APP_URL').'/storage/app/public',
'visibility' => 'public',
],
And now I can upload and see the images in file manager and inside the web app. But now the problem is that users can visit the image url and see the private route of the folder:
http//mi_lar_app/storage/app/public/photos/31/art_1/fig_1.0.png
Some help????
If you have similar problems, the procedure I do in this case was to create a symbolic link with routes (I created a php file because I haven't access to SSH on my server):
<?php
/*__DIR__ is the directory file, where you save this file.php */
$mytargetDIR = __DIR__.'/../mi_lar_app/storage';
$mylinkDIR = __DIR__.'/storage';
symlink($mytargetDIR,$mylinkDIR);
echo 'Todo ok/ Symlink process successfully completed';
?>
And important, remember clean cache and routes every changes. If you don't have SSH access:
<?php
Artisan::call('cache:clear');
Artisan::call('config:cache');
Artisan::call('route:cache');
Artisan::call('view:clear');
return 'Todo limpio/All is cleaned';
?>
And next this little explanation, some help to me?? :)

How to get authenticated users cached on drupal with or without authcache

Could use some help. I have a drupal6 install that im having trouble with in terms of caching for authenticated users. Boost is handling the none authenticated caching very well. With my current setup, sessions cannot be created at all, when attempting to login the result is "You are not authorized to view this page". Memcache and apc are installed on the server and working according to phpinfo. Here is my current setup (without cacherouter):
include_once('./sites/all/modules/memcache/memcache.inc');
$conf['cache_default_class'] = 'MemCacheDrupal';
$conf['session_inc'] = './sites/all/modules/memcache/memcache-session.inc';
$conf['memcache_servers'] = array(
'127.0.0.1:11211' => 'default',
'127.0.0.1:11212' => 'block',
'127.0.0.1:11213' => 'content',
'127.0.0.1:11214' => 'filter',
'127.0.0.1:11215' => 'form',
'127.0.0.1:11216' => 'menu',
'127.0.0.1:11217' => 'page',
'127.0.0.1:11218' => 'update',
'127.0.0.1:11219' => 'views',
'127.0.0.1:11221' => 'session',
'127.0.0.1:11222' => 'users'
);
$conf['memcache_bins'] = array(
'cache' => 'default',
'cache_block' => 'block',
'cache_content' => 'content',
'cache_filter' => 'filter',
'cache_form' => 'form',
'cache_menu' => 'menu',
'cache_page' => 'page',
'cache_update' => 'update',
'cache_views' => 'views',
'session' => 'session',
'users' => 'users'
);
Before this setup, I was using cacherouter with authcache and had apc as the engine. Users could log in, but there was no actual caching happening for authenticated users. I have been reading everything I could find on this to get it going, doing various test and changing configurations, but without success. Here was the previous setup:
$conf['cacherouter'] = array(
'default' => array(
'engine' => 'apc',
'server' => array('127.0.0.1:11211'),
'shared' => TRUE,
'prefix' => '',
'path' => 'storage_bin/filecache',
'static' => FALSE
),
);
$conf['cache_inc'] = './sites/all/modules/authcache/authcache.inc';
$conf['memcache_servers'] = array(
'127.0.0.1:11211' => 'default',
'127.0.0.1:11212' => 'block',
'127.0.0.1:11213' => 'content',
'127.0.0.1:11214' => 'filter',
'127.0.0.1:11215' => 'form',
'127.0.0.1:11216' => 'menu',
'127.0.0.1:11217' => 'page',
'127.0.0.1:11218' => 'update',
'127.0.0.1:11219' => 'views'
);
$conf['memcache_bins'] = array(
'cache' => 'default',
'cache_block' => 'block',
'cache_content' => 'content',
'cache_filter' => 'filter',
'cache_form' => 'form',
'cache_menu' => 'menu',
'cache_page' => 'page',
'cache_update' => 'update',
'cache_views' => 'views'
);
The site is visible at www.thewildside.com. Any help on this would be greatly appreciated.
If anyone else runs into this, my solution was to ditch cacherouter (did not perform as expected), authcache(too beta), and boost (simply to avoid hitting apache at all for cached pages)… proceeding with Memcache API (the drupal module), memcache (the caching system), apc and varnish (3.0). Memcache API allows me to cache both to RAM via memcache and to the drupal db as backup in case memcache is not available (via memcache.db.inc). Benchmark to determine how much RAM to use for each cache component. I can also keep session info in memcache, but I have not noticed a great performance gain with this, so you may choose not to include memcache-session.inc. Create memcache instances for each drupal cache db (or use one default instance). Setup a cache bin for each instance you've created, and throw in reverse proxy settings and default ttl. Here is my whats in my setting.php file;
$conf = array(
'cache_inc' => './sites/all/modules/memcache/memcache.db.inc',
'memcache_key_prefix' => 'ws',
'session_inc' => './sites/all/modules/memcache/memcache-session.inc',
'memcache_servers' => array(
'unix:///var/run/memcached/memcached_wildside.sock' => 'default',
'unix:///var/run/memcached/memcached_wildside_apachesolr.sock' => 'apachesolr',
'unix:///var/run/memcached/memcached_wildside_block.sock' => 'block',
'unix:///var/run/memcached/memcached_wildside_content.sock' => 'content',
'unix:///var/run/memcached/memcached_wildside_filter.sock' => 'filter',
'unix:///var/run/memcached/memcached_wildside_form.sock' => 'form',
'unix:///var/run/memcached/memcached_wildside_media_youtube_status.sock' => 'media_youtube_status',
'unix:///var/run/memcached/memcached_wildside_menu.sock' => 'menu',
'unix:///var/run/memcached/memcached_wildside_objects.sock' => 'objects',
'unix:///var/run/memcached/memcached_wildside_page.sock' => 'page',
'unix:///var/run/memcached/memcached_wildside_path.sock' => 'path',
'unix:///var/run/memcached/memcached_wildside_rules.sock' => 'rules',
'unix:///var/run/memcached/memcached_wildside_update.sock' => 'update',
'unix:///var/run/memcached/memcached_wildside_views.sock' => 'views',
'unix:///var/run/memcached/memcached_wildside_views_data.sock' => 'views_data',
'unix:///var/run/memcached/memcached_wildside_session.sock' => 'session',
'unix:///var/run/memcached/memcached_wildside_users.sock' => 'users'),
'memcache_bins' => array(
'cache' => 'default',
'cache_apachesolr' => 'apachesolr',
'cache_block' => 'block',
'cache_content' => 'content',
'cache_filter' => 'filter',
'cache_form' => 'form',
'cache_media_youtube_status' => 'media_youtube_status',
'cache_menu' => 'menu',
'cache_objects' => 'objects',
'cache_page' => 'page',
'cache_path' => 'path',
'cache_rules' => 'rules',
'cache_update' => 'update',
'cache_views' => 'views',
'cache_views_data' => 'views_data',
'session' => 'session',
'users' => 'users'),
);
$conf['https'] = TRUE;
$conf['mimedetect_magic'] = '/usr/share/file/magic';
$conf['reverse_proxy'] = TRUE;
$conf['reverse_proxy_addresses'] = array('127.0.0.1');
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])){
if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
$_SERVER['HTTPS']='on';
}else{
$_SERVER['HTTPS']='';
}
}
/* 1 day cache lifetime = 86400 */
$conf['cache_lifetime'] = 86400;
$conf['page_cache_maximum_age'] = 86400;
When setting up Varnish's config file (.vcl), just be sure that the syntax you use corresponds to the version of varnish you have installed.

Resources