Giter VIP home page Giter VIP logo

upload's Introduction

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();

upload's People

Contributors

recca0120 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

upload's Issues

Trouble with modifying storage paths

I'm successfully uploading using FineUploader with chunking, but I'd like to modify the storage paths for where the files are stored, as I can't have the photos publicly available. Can you tell me where to modify this data? I tried changing it in the API.PHP file, but that wasn't it. My files are being saved currently to a temp folder in the public/storage area. I'd like to put them into a storage_path location called 'imageuploads'. Thanks very much!

File not found

After finishing upload $uploadedFile file doesn't exist and Symfony returns unknown error while upload chucked file.

$receiver = new Receiver(new FileAPI($config)); and then no more....

Hi Recca, thanks for sharing this wonderful package, I'm here to ask you about how to use your gorgeous upload package, when I execute your demo index.html included, uploading files but it crashed at line "$receiver = new Receiver(new FileAPI($config));" and not any error message show, would you please be kind to instruct me what is going wrong here? thanks:)
Besides how do I set the config file correctly, is the path(temp/chunks) relative to what position. and where should I create these folder? Could you explain more in your readme file.

Thanks very much ^^
Ryan

file uploaded successfully,but got error from server side

$driver = 'plupload'; // or 'fileapi'
        $inputName = 'file'; // $_FILES index;
        $storagePath = 'storage/temp';

        return $manager
            ->driver($driver)
            ->receive($inputName, function (UploadedFile $uploadedFile, $path, $root, $url, $api) {
                // do something

            });

I use this for server code , and the file uploaded , but I got this error from server side~

Missing argument 5 for App\Http\Controllers\UploadController::App\Http\Controllers\{closure}()

is there any problems in ->receive($inputName, function (UploadedFile $uploadedFile, $path, $root, $url, $api) {}); ????

Server response a error while using Laravel

Hi, I got this error message while using Fineuploader + Laravel to upload:

Type error: Argument 1 passed to Recca0120\Upload\FineUploader::completedResponse() must be an instance of Illuminate\Http\JsonResponse, null given, called in D:\wamp\www\laravel\vendor\recca0120\upload\src\Receiver.php on line 49

Javascript:

<script>
    var uploader = new qq.FineUploader({
        element: document.getElementById("fine-uploader"),
        debug: true,
        request: {
            endpoint: "http://laravel.work/upload",
            inputName: 'file',
        },
        chunking: {
            enabled: true,
            concurrent: {
                enabled: true
            },
            success: {
                endpoint: "http://laravel.work/upload"
            }
        },
        resume: {
            enabled: true
        },
        retry: {
            enableAuto: true,
            showButton: true
        }
    })
</script>

routes\web.php:
Route::post('upload', 'UploadController@upload');

Controller:

class UploadController extends Controller
{
    public function upload(UploadManager $manager)
    {
        $driver = 'fine-uploader';
        $inputName = 'file';
        $storagePath = 'storage/temp';

        return $manager
            ->driver($driver)
            ->receive($inputName, function (UploadedFile $uploadedFile, $path, $domain, $api) {
                // do something

            });
    }
}

But if I using your demo code directly, everything works fine, maybe there is something I forgot to set?

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.