runsite/laravel-filemanager

This package is abandoned and no longer maintained. No replacement package was suggested.

A file upload/editor intended for use with Laravel 5.3.* and CKEditor

0.63 2016-12-18 09:54 UTC

README

Latest Stable Version Total Downloads Latest Unstable Version License

laravel-filemanager

A file upload/editor intended for use with Laravel 5.x and CKEditor.

Rationale

There are other packages out there that offer much the same functionality, such as KCFinder, but I found that integration with Laravel was a bit problematic, particularly when it comes to handling sessions and security.

This package is written specifically for Laravel 5, and will integrate seamlessly.

Requirements

  1. This package only supports Laravel 5.x.
  2. Requires "intervention/image": "2.*"
  3. Requres "laravelcollective/html": "5.2.*"
  4. Requires PHP 5.5 or later

Installation

  1. Installation is done through composer and packagist. From within your project root directory, execute the following command:

    composer require runsite/laravel-filemanager

  2. Add the following to the providers array in config/app.php:

    Runsite\Laravelfilemanager\LaravelFilemanagerServiceProvider::class,
    Intervention\Image\ImageServiceProvider::class,
    Collective\Html\HtmlServiceProvider::class,
    
  3. Add this to the aliases section in config/app.php

    'Image'     => Intervention\Image\Facades\Image::class,
    'Form' => Collective\Html\FormFacade::class,
    'Html' => Collective\Html\HtmlFacade::class,
    
  4. Publish the package's config file:

    php artisan vendor:publish --tag=lfm_config

  5. Publish the package's public folder assets:

    php artisan vendor:publish --tag=lfm_public

  6. If you want to customize the look & feel, then publish the package's views:

    php artisan vendor:publish --tag=lfm_views

  7. By default, the package will use its own routes. If you don't want to use those routes, change this entry in config/lfm.php to false:

        'use_package_routes' => true,

    You will, of course, have to set up your own routes.

  8. If you don't want to use the default image/file directory or url, update the appropriate lines in config/lfm.php:

        'images_dir'         => 'public/vendor/laravel-filemanager/images/',
        'images_url'         => '/vendor/laravel-filemanager/images/',
        'files_dir'          => 'public/vendor/laravel-filemanager/files/',
        'files_url'          => '/vendor/laravel-filemanager/files/',
  9. Ensure that the files & images directories are writable by your web serber

  10. In the view where you are using a CKEditor instance, use the file uploader by initializing the CKEditor instance as follows:

        <script>
            CKEDITOR.replace( 'editor', {
                filebrowserImageBrowseUrl: '{{asset('/runsite/laravel-filemanager?type=Images')}}',
                filebrowserBrowseUrl: '{{asset('/runsite/laravel-filemanager?type=Files')}}'
            });
        </script>

    Here, "editor" is the id of the textarea you are transforming to a CKEditor instance. Note that if you are using a custom route you will have to change /runsite/laravel-filemanager?type=Images to correspond to whatever route you have chosen. Be sure to include the ?type=Images parameter.

Security

It is important to note that if you use your own routes you must protect your routes to Laravel-Filemanager in order to prevent unauthorized uploads to your server. Fortunately, Laravel makes this very easy.

If, for example, you want to ensure that only logged in users have the ability to access the Laravel-Filemanager, simply wrap the routes in a group, perhaps like this:

Route::group(array('before' => 'auth'), function ()
{
    Route::get('/runsite/laravel-filemanager', '\Runsite\Laravelfilemanager\controllers\LfmController@show');
    Route::post('/runsite/laravel-filemanager/upload', '\Runsite\Laravelfilemanager\controllers\LfmController@upload');
    // list all lfm routes here...
});

This approach ensures that only authenticated users have access to the Laravel-Filemanager. If you are using Middleware or some other approach to enforce security, modify as needed.

License

This package is released under the terms of the MIT License.

The MIT License (MIT)

Copyright (c) 2015 Trevor Sawler, Runsite LLC

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.