Giter Club home page Giter Club logo

laravel-plupload's Introduction

laravel-plupload

Laravel plupload support.

Handeling chunked uploads.

Installation

Install using composer

composer require jildertmiedema/laravel-plupload

Add the provider to config/app.php

'providers' => [
    JildertMiedema\LaravelPlupload\LaravelPluploadServiceProvider::class,
]

If you want to use te build in builder insert the facade

'aliases' => array(
    'Plupload' => JildertMiedema\LaravelPlupload\Facades\Plupload::class,
),

To publish the assets:

php artisan vendor:publish

Receiving files

Use this route to receive a file on the url /upload. Of course you can place this is a controller.

Route::post('/upload', function()
{
    return Plupload::receive('file', function ($file)
    {
        $file->move(storage_path() . '/test/', $file->getClientOriginalName());

        return 'ready';
    });
});

Sending files

There are 3 ways to send files with this plugin.

1. Use default plupload html

Use the examples found on the plupload site.

Issues

If you are encountering a Token Mismatch Exception;

TokenMismatchException in VerifyCsrfToken.php line 53:

add in your blade file

<meta name="csrf-token" content="{{ csrf_token() }}">

in your JS file, add

headers: {
        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    },

Eg:

$('.js-uploader').pluploadQueue({

	// General settings
	runtimes: 'html5,flash,silverlight,html4',
	url: '/upload/',
	chunk_size: '200kb',
    rename: false,
    dragdrop: true,
	// add X-CSRF-TOKEN in headers attribute to fix this issue
	headers: {
        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    },
	// add more overrides; see documentation...

});

2. Simple plupload builder

To use the builder for creating send form you can use this function:

echo Plupload::make([
    'url' => 'upload',
    'chunk_size' => '100kb',
]);

Note: The options given to the make function are found on in the pluload documentation.

3. Extended plupload builder

echo Plupload::init([
    'url' => 'upload',
    'chunk_size' => '100kb',
])->withPrefix('current')->createHtml();

Alternatives

Other packages supporting plupload:

laravel-plupload's People

Contributors

jildertmiedema avatar aginev avatar gilbitron avatar askippers avatar piroz avatar liorocks avatar resoftw avatar umarmw avatar michalmrzyk avatar stevebauman avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.