2017 © Pedro Peláez
 

library laravel-uploader

image

overtrue/laravel-uploader

  • Thursday, April 19, 2018
  • by overtrue
  • Repository
  • 6 Watchers
  • 66 Stars
  • 5,360 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 11 Forks
  • 4 Open issues
  • 9 Versions
  • 15 % Grown

The README.md

Laravel Uploader

:palm_tree: An upload component for Laravel., (*1)

Sponsor me, (*2)

Installing

  1. Install package:, (*3)

    $ composer require overtrue/laravel-uploader -vvv
    

    and publish the assets using command:, (*4)

    $ php artisan vendor:publish --provider=Overtrue\\LaravelUploader\\UploadServiceProvider
    
  2. Routing, (*5)

    You can register routes in routes/web.php or other routes file:, (*6)

    \LaravelUploader::routes();
    
    // custom
    \LaravelUploader::routes([
       'as' => 'files.upload', 
       'middleware' => ['auth'],
       //...
    ]); 
    

Usage

Custom controller

If you want to handle file upload, you can do it as simple as:, (*7)

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Routing\Controller as BaseController;
use Overtrue\LaravelUploader\StrategyResolver;

class MyUploadController extends BaseController
{
    public function upload(Request $request)
    {
        return StrategyResolver::resolveFromRequest($request, $request->get('strategy', 'default'))->upload();
    }
}

Custom Response

If you want update the response, you can get key information from the return value object and return a new response:, (*8)

    public function upload(Request $request)
    {
        $response = StrategyResolver::resolveFromRequest($request, $request->get('strategy', 'default'))->upload();

        return response()->json([
            'status' => 'success',
            'url' => $response->url,
            'origin_name' => $response->originalName,
            //...
        ]);
    }

You can get all these public properties:, (*9)

int $size;
string $path;
string $mime;
string $url;
string $relativeUrl;
string $filename;
string $originalName;
\Illuminate\Http\UploadedFile   $file;
\Overtrue\LaravelUploader\Strategy $strategy;

Recommend clients

:heart: Sponsor me

Sponsor me, (*10)

如果你喜欢我的项目并想支持它,点击这里 :heart:, (*11)

Project supported by JetBrains

Many thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects., (*12)

, (*13)

PHP 扩展包开发

想知道如何从零开始构建 PHP 扩展包?, (*14)

请关注我的实战课程,我会在此课程中分享一些扩展开发经验 —— 《PHP 扩展包实战教程 - 从入门到发布》, (*15)

License

MIT, (*16)

The Versions

19/04 2018

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

by Avatar overtrue

13/04 2018

0.0.8

0.0.8.0

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

by Avatar overtrue

31/07 2017

0.0.7

0.0.7.0

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

by Avatar overtrue

18/07 2017

0.0.6

0.0.6.0

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

by Avatar overtrue

27/06 2017

0.0.5

0.0.5.0

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

by Avatar overtrue

27/06 2017

0.0.4

0.0.4.0

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

by Avatar overtrue

27/06 2017

0.0.3

0.0.3.0

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

by Avatar overtrue

25/06 2017

0.0.2

0.0.2.0

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

by Avatar overtrue

02/04 2017

0.0.1

0.0.1.0

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

by Avatar overtrue