Skip to content
Ajax Upload Large File Support jQuery-File-Upload, FileApi, Plupload, Dropzone Support framework Laravel 5
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
docs/demo
src
tests
.editorconfig
.gitattributes
.gitignore
.nitpick.json
.php_cs
.scrutinizer.yml
.styleci.yml
.travis.yml
CHANGELOG.md
LICENSE
README.md
appveyor.yml
composer.json
phpcs.xml
phpunit.xml.dist
ruleset.xml

README.md

Donate

Pure Ajax Upload And for Laravel 5 (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

Instead, you may of course manually update your require block and run composer update if you so choose:

{
    "require": {
        "recca0120/upload": "^1.7"
    }
}

Laravel 5

Include the service provider within config/app.php. The service povider is needed for the generator artisan command.

'providers' => [
    ...
    Recca0120\Upload\UploadServiceProvider::class,
    ...
];

publish

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

How to use

Controller


use Illuminate\Http\JsonResponse;
use Recca0120\Upload\UploadManager;
use Symfony\Component\HttpFoundation\File\UploadedFile;

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) {
                $clientOriginalName = $uploadedFile->getClientOriginalName();
                $clientOriginalExtension = strtolower($uploadedFile->getClientOriginalExtension());
                $basename = pathinfo($uploadedFile->getBasename(), PATHINFO_FILENAME);
                $filename = md5($basename).'.'.$clientOriginalExtension;
                $mimeType = $uploadedFile->getMimeType();
                $size = $uploadedFile->getSize();
                $uploadedFile->move($path, $filename);
                $response = [
                    'name' => pathinfo($clientOriginalName, PATHINFO_FILENAME).'.'.$clientOriginalExtension,
                    'tmp_name' => $path.$filename,
                    'type' => $mimeType,
                    'size' => $size,
                    'url' => $domain.$path.$filename,
                ];

                return new JsonResponse($response);

            });
    }
}

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'
];

$inputName = 'file';
$storagePath = 'relative path';
$api = 'fileapi'; // or plupload

Receiver::factory($config, $api)->receive($inputName)->send();

Standalone


use Recca0120\Upload\Receiver;
use Recca0120\Upload\FileAPI;
use Recca0120\Upload\Plupload;
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'
];

$inputName = 'file';
$storagePath = 'relative path';

// if use Plupload, new Recca0120\Upload\Plupload
$receiver = new Receiver(new FileAPI($config));
// save to $config['base_path'].'/'.$storagePath;
$receiver->receive($inputName)->send();
You can’t perform that action at this time.