visit
: Open Protocol for Resumable File Uploads. : A pure PHP server and client for the tus resumable upload protocol v1.0.0. : An open-source (BSD licensed), in-memory data structure store, used as a database, cache, and message broker.
npm install uppy
npm install @uppy/dashboard
npm install @uppy/tus
<button type='button' class='btn btn-success btn-sm' id='file_upload' name='file_upload'>Upload File</button>
<meta name="csrf-token" content={"{ csrf_token() }}">
import Uppy from '@uppy/core';
import Tus from '@uppy/tus'
import Dashboard from '@uppy/dashboard';
const uppy = new Uppy({
debug: false,
autoProceed: false,
restrictions: {
maxFileSize: 1000000,
maxNumberOfFiles: 1,
allowedFileTypes: ['image/*'],
}
})
.use(Dashboard, {
target: 'body',
trigger: '#file_upload',
closeAfterFinish: true,
browserBackButtonClose: false,
showProgressDetails: true,
})
.use(Tus, {
endpoint: '/tus', // use your tus endpoint here
retryDelays: [0, 1000, 3000, 5000],
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
})
curl -fsSL //packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] //packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
sudo apt-get update
sudo apt-get install redis
redis-server
redis-cli ping
composer require ankitpokhrel/tus-php
php artisan make:provider TusServiceProvider
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use TusPhp\Tus\Server as TusServer;
class TusServiceProvider extends ServiceProvider
{
/**
* Register services.
*
* @return void
*/
public function register()
{
//
$this->app->singleton('tus-server', function ($app) {
$server = new TusServer('redis');
$server->setApiPath('/tus');
$server->setUploadDir(storage_path('app/public/uploads'));
return $server;
});
}
/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
//
}
}
Route::any('/tus/{any?}', function () {
return app('tus-server')->serve();
})->where('any', '.*');
Also Published