2017 © Pedro Peláez
 

library laravel-plupload

Plupload package for Laravel 5

image

jenky/laravel-plupload

Plupload package for Laravel 5

  • Saturday, June 16, 2018
  • by Milano
  • Repository
  • 2 Watchers
  • 22 Stars
  • 10,007 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 6 Forks
  • 3 Open issues
  • 21 Versions
  • 6 % Grown

The README.md

Laravel 5 Plupload

Latest Stable Version Total Downloads License, (*1)

Laravel package for Plupload http://plupload.com.

This package uses some parts of https://github.com/jildertmiedema/laravel-plupload, (*2)

Installation

Require this package with composer:, (*3)

composer require jenky/laravel-plupload

Laravel 5.5+ uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider., (*4)

For Laravel 5.4 or older, (*5)

Add the ServiceProvider to the providers array in config/app.php, (*6)

Jenky\LaravelPlupload\PluploadServiceProvider::class,

and add this to your facades in config/app.php:, (*7)

'Plupload' => Jenky\LaravelPlupload\Facades\Plupload::class,

Copy the package config to your local config with the publish command:, (*8)

php artisan vendor:publish

or, (*9)

php artisan vendor:publish --provider="Jenky\LaravelPlupload\PluploadServiceProvider"

Usage

Uploading files

1. Use default plupload html

Use the examples found on the plupload site. The Getting Started page is good place to start., (*10)

2. Plupload builder

make($id, $url), (*11)

Create new uploader. * $id: the unique identification for the uploader. * $url: the upload url end point., (*12)

{!! Plupload::make('my_uploader_id', route('photos.store'))->render() !!}

or use the helper, (*13)

{!! plupload()->make('my_uploader_id', route('photos.store')) !!}
// or even shorter
{!! plupload('my_uploader_id', route('photos.store')) !!}

render($view = 'plupload::uploader', array $data = []), (*14)

Renders the uploader. You can customize this by passing a view name and it's data. From version 2.0, you can omit the render method in the builder if you don't want to set the view or extra data., (*15)

3. Use package js file to initialize Plupload (Optional)

If you do not want to write your own js to initialize Plupload, you can use the upload.js file that included with the package in resources/views/vendor/plupload/assets/js. Make sure that you already have jQuery loaded on your page., (*16)

Initialize Plupload, (*17)

<script>
$(function () {
    createUploader('my_uploader_id'); // The Id that you used to create with the builder
});
</script>

These following methods are useable with the upload.js file., (*18)

Set Uploader options, (*19)

setOptions(array $options), (*20)

Set uploader options. Please visit https://github.com/moxiecode/plupload/wiki/Options to see all the options. You can set the default global options in config/plupload.php, (*21)

{!! plupload('my_uploader_id', route('photos.store'))
    ->setOptions([
        'filters' => [
            'max_file_size' => '2mb',
            'mime_types' => [
                ['title' => 'Image files', 'extensions' => 'jpg,gif,png'],
            ],
        ],
    ]) !!}

Automatically start upload when files added, (*22)

Use setAutoStart() in your builder before calling render() function., (*23)

setAutoStart($bool), (*24)

  • $bool: true or false
{!! plupload('my_uploader_id', route('photos.store'))->setAutoStart(true) !!}

Receiving files

file($name, $handler) * $name: the input name. * $handler: callback handler., (*25)

Use this in your route or your controller. Feel free to modify to suit your needs., (*26)

return Plupload::file('file', function($file) {
    // Store the uploaded file using storage disk
    $path = Storage::disk('local')->putFile('photos', $file);

    // Save the record to the db
    $photo = App\Photo::create([
        'name' => $file->getClientOriginalName(),
        'type' => 'image',
        // ...
    ]);

    // This will be included in JSON response result
    return [
        'success' => true,
        'message' => 'Upload successful.',
        'id' => $photo->id,
        // 'url' => $photo->getImageUrl($filename, 'medium'),
        // 'deleteUrl' => route('photos.destroy', $photo)
        // ...
    ];
});

Helper is also available, (*27)

return plupload()->file('file', function($file) {

});

If you are using the package upload.js file. The url and deleteUrl in the JSON payload will be used to generate preview and delete link while the id will be appended to the uploader as a hidden field with the following format:, (*28)

<input type="hidden" name="{uploaderId}_files[]" value="{id}" />., (*29)

Please note that the deleteUrl uses DELETE method., (*30)

The Versions

16/06 2018

dev-master

9999999-dev

Plupload package for Laravel 5

  Sources   Download

MIT

The Requires

 

by Linh Tran

laravel plupload

16/06 2018

3.0.0

3.0.0.0

Plupload package for Laravel 5

  Sources   Download

MIT

The Requires

 

by Linh Tran

laravel plupload

03/05 2018

dev-develop

dev-develop

Plupload package for Laravel 5

  Sources   Download

MIT

The Requires

 

by Linh Tran

laravel plupload

26/04 2018

2.x-dev

2.9999999.9999999.9999999-dev

Plupload package for Laravel 5

  Sources   Download

MIT

The Requires

 

by Linh Tran

laravel plupload

16/06 2017

dev-dev

dev-dev

Plupload package for Laravel 5

  Sources   Download

MIT

The Requires

 

by Linh Tran

laravel plupload

16/06 2017

2.0.0

2.0.0.0

Plupload package for Laravel 5

  Sources   Download

MIT

The Requires

 

by Linh Tran

laravel plupload

08/05 2017

1.x-dev

1.9999999.9999999.9999999-dev

Plupload package for Laravel 5

  Sources   Download

MIT

The Requires

 

by Linh Tran

laravel plupload

07/02 2017

1.2.2

1.2.2.0

Plupload package for Laravel 5.0

  Sources   Download

MIT

The Requires

 

by Linh Tran

laravel plupload

05/04 2016

1.2.1

1.2.1.0

Plupload package for Laravel 5.0

  Sources   Download

MIT

The Requires

 

by Linh Tran

laravel plupload

01/02 2016

1.2.0

1.2.0.0

Plupload package for Laravel 5.0

  Sources   Download

MIT

The Requires

 

by Linh Tran

laravel plupload

03/07 2015

1.1.8

1.1.8.0

Plupload package for Laravel 5.0

  Sources   Download

MIT

The Requires

 

by Linh Tran

laravel plupload

17/06 2015

1.1.7

1.1.7.0

Plupload package for Laravel 5.0

  Sources   Download

MIT

The Requires

 

by Linh Tran

laravel plupload

11/06 2015

1.1.6

1.1.6.0

Plupload package for Laravel 5.0

  Sources   Download

MIT

The Requires

 

by Linh Tran

laravel plupload

14/04 2015

1.1.5

1.1.5.0

Plupload package for Laravel 5.0

  Sources   Download

MIT

The Requires

 

by Linh Tran

laravel plupload

10/04 2015

1.1.4

1.1.4.0

Plupload package for Laravel 5.0

  Sources   Download

The Requires

 

by Linh Tran

laravel plupload

08/04 2015

1.1.3

1.1.3.0

Plupload package for Laravel 5.0

  Sources   Download

The Requires

 

by Linh Tran

laravel plupload

07/04 2015

1.1.2

1.1.2.0

Plupload package for Laravel 5.0

  Sources   Download

The Requires

 

by Linh Tran

laravel plupload

07/04 2015

1.1.1

1.1.1.0

Plupload package for Laravel 5.0

  Sources   Download

The Requires

 

by Linh Tran

laravel plupload

07/04 2015

1.1.0

1.1.0.0

Plupload package for Laravel 5.0

  Sources   Download

The Requires

 

by Linh Tran

laravel plupload

07/04 2015

1.0.1

1.0.1.0

Plupload package for Laravel 5.0

  Sources   Download

The Requires

 

by Linh Tran

laravel plupload

07/04 2015

1.0.0

1.0.0.0

Plupload package for Laravel 5.0

  Sources   Download

The Requires

 

by Linh Tran

laravel plupload