Skip to content

Ajax Upload Large File Support jQuery-File-Upload, FileApi, Plupload, Dropzone, Filepond for Laravel

License

Notifications You must be signed in to change notification settings

recca0120/upload

Repository files navigation

Donate

Pure Ajax Upload And for Laravel (Support jQuery-File-Upload, FileApi, Plupload)

StyleCI Build Status Total Downloads Latest Stable Version Latest Unstable Version License Monthly Downloads Daily Downloads Scrutinizer Code Quality Code Coverage

Features

Installing

To get the latest version of Laravel Exceptions, simply require the project using Composer:

composer require recca0120/upload

Laravel

publish

artisan vendor:publish --provider="Recca0120\Upload\UploadServiceProvider"

How to use

Controller

use Illuminate\Http\JsonResponse;
use Illuminate\Http\UploadedFile;
use Recca0120\Upload\UploadManager;

class UploadController extends Controller
{
    public function upload(UploadManager $manager)
    {
        $driver = 'plupload'; // or 'fileapi'
        $inputName = 'file'; // $_FILES index;

        return $manager->driver($driver)->receive($inputName);

        // or
        return $manager
            ->driver($driver)
            ->receive($inputName, function (UploadedFile $uploadedFile, $path, $domain, $api) {
                $filename = $uploadedFile->getBasename();

                return new JsonResponse([
                    'name' => $uploadedFile->getClientOriginalName(),
                    'tmp_name' => $path.$filename,
                    'type' => $uploadedFile->getMimeType(),
                    'size' => $uploadedFile->getSize(),
                    'url' => $domain.$path.$filename,
                ]);
            });
    }
}

Factory

use Recca0120\Upload\Receiver;
use Illuminate\Http\JsonResponse;

require __DIR__.'/vendor/autoload.php';

$config = [
    'chunks' => 'path_to_chunks',
    'storage' => 'path_to_storage',
    'domain' => 'http://app.dev/',
    'path' => 'web_path'
];

Receiver::factory($config, 'fileapi')->receive('file')->send();

Standalone

use Recca0120\Upload\Drivers\FileAPI;
use Recca0120\Upload\Receiver;

require __DIR__.'/vendor/autoload.php';

$config = [
    'chunks' => 'path_to_chunks',
    'storage' => 'path_to_storage',
    'domain' => 'http://app.dev/',
    'path' => 'web_path'
];

// if use Plupload, new Recca0120\Upload\Plupload
$receiver = new Receiver(new FileAPI($config));
// save to $config['storage'];
$receiver->receive('file')->send();

About

Ajax Upload Large File Support jQuery-File-Upload, FileApi, Plupload, Dropzone, Filepond for Laravel

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages