Laravel Upload Support Plupload AND FileApi

介绍

Ajax 文件上传组件。

项目地址:https://github.com/recca0120/laravel-uploa...

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.2.0"
    }
}

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

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

How to use

Controller


use Recca0120\Upload\Manager;
use Symfony\Component\HttpFoundation\File\UploadedFile;

class UploadController extends Controller
{
    public function upload(Manager $manager)
    {
        $driver = 'plupload'; // or 'fileapi'
        $name = 'file'; // $_FILES index;
        return $manager
            ->driver($driver)
            ->receive($name, function (UploadedFile $file) {

                $clientOriginalName = $file->getClientOriginalName();
                $pathName = $file->getPathname();
                $mimeType = $file->getMimeType();
                $size = $file->getSize();

                return response()->json([
                    'name'     => $clientOriginalName,
                    'type'     => $mimeType,
                    'size'     => $size,
                ]);
            });
    }
}
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
讨论数量: 2
Summer

我加了一段介绍,还贴了下项目地址。 :bowtie:

8年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!