DEV Community

Cover image for Filemanger In Laravel 5.8
Hòa Nguyễn Coder
Hòa Nguyễn Coder

Posted on

Filemanger In Laravel 5.8

Installing laravel-filemanger

composer require unisharp/laravel-filemanager

Config file config/app.php

//providers add line two
Unisharp\Laravelfilemanager\LaravelFilemanagerServiceProvider::class,
Intervention\Image\ImageServiceProvider::class,

//aliases add line

'Image' => Intervention\Image\Facades\Image::class,

if version Laravel > 5.5, you don't command install

php artisan vendor:publish --tag=lfm_config

php artisan vendor:publish --tag=lfm_public

Delete cache:

php artisan route:clear

php artisan config:clear

You can set chmod folder upload images in config/lfm.php

Installing auth in laravel

php artisan make:Auth

//confing web.php

Route::group(['middleware' => 'auth'], function () {
Route::get('/laravel-show', function(){
return View('filemanager');
});
Route::get('/laravel-filemanager', '\UniSharp\LaravelFilemanager\Controllers\LfmController@show');
Route::post('/laravel-filemanager/upload', '\UniSharp\LaravelFilemanager\Controllers\UploadController@upload');

// list all lfm routes here...
Enter fullscreen mode Exit fullscreen mode

});

You need create file in folder views/filemanger.blade.php

var options = {
filebrowserImageBrowseUrl: '/laravel-filemanager?type=Images',
filebrowserImageUploadUrl: '/laravel-filemanager/upload?type=Images&_token=',
filebrowserBrowseUrl: '/laravel-filemanager?type=Files',
filebrowserUploadUrl: '/laravel-filemanager/upload?type=Files&_token='
};
CKEDITOR.replace('editor', options);

Install filemanger in laravel success

php artisan server

You need before login in laravel, aften then you can open brower
http://localhost:8000/laravel-show/

Post:http://hoanguyenit.com/filemanger-in-laravel-5-8.html

Top comments (0)