MyGit

jildertmiedema/laravel-plupload

Fork: 59 Star: 168 (更新于 2024-10-26 02:51:41)

license: MIT

Language: JavaScript .

Laravel plupload support - Handle large file uploads

最后发布版本: V0.9.0 ( 2023-05-05 19:14:53)

GitHub网址

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:

最近版本更新:(数据更新于 2024-10-20 10:34:39)

2023-05-05 19:14:53 V0.9.0

2022-04-01 20:26:51 V0.8.0

2020-05-19 19:30:22 V0.6.0

jildertmiedema/laravel-plupload同语言 JavaScript最近更新仓库

2024-11-05 19:13:47 jerryc127/hexo-theme-butterfly

2024-11-05 13:53:42 LiteLoaderQQNT/LiteLoaderQQNT

2024-11-03 02:40:36 chris81605/Degrees-of-Lewdity_Cheat_Extended

2024-11-01 21:55:46 projectdiscovery/nuclei-templates

2024-11-01 19:24:44 NumberSir/DoL-I18n-Build

2024-11-01 12:25:14 midoks/mdserver-web