承接 jenky/laravel-plupload 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jenky/laravel-plupload

Composer 安装命令:

composer require jenky/laravel-plupload

包简介

Plupload package for Laravel 5

README 文档

README

Latest Stable Version Total Downloads License

Laravel package for Plupload http://plupload.com.

This package uses some parts of https://github.com/jildertmiedema/laravel-plupload

Installation

Require this package with composer:

composer require jenky/laravel-plupload

Laravel 5.5+ uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.

For Laravel 5.4 or older

Add the ServiceProvider to the providers array in config/app.php

Jenky\LaravelPlupload\PluploadServiceProvider::class,

and add this to your facades in config/app.php:

'Plupload' => Jenky\LaravelPlupload\Facades\Plupload::class,

Copy the package config to your local config with the publish command:

php artisan vendor:publish

or

php artisan vendor:publish --provider="Jenky\LaravelPlupload\PluploadServiceProvider"

Usage

Uploading files

1. Use default plupload html

Use the examples found on the plupload site. The Getting Started page is good place to start.

2. Plupload builder

make($id, $url)

Create new uploader.

  • $id: the unique identification for the uploader.
  • $url: the upload url end point.
{!! Plupload::make('my_uploader_id', route('photos.store'))->render() !!}

or use the helper

{!! plupload()->make('my_uploader_id', route('photos.store')) !!}
// or even shorter
{!! plupload('my_uploader_id', route('photos.store')) !!}

render($view = 'plupload::uploader', array $data = [])

Renders the uploader. You can customize this by passing a view name and it's data. From version 2.0, you can omit the render method in the builder if you don't want to set the view or extra data.

3. Use package js file to initialize Plupload (Optional)

If you do not want to write your own js to initialize Plupload, you can use the upload.js file that included with the package in resources/views/vendor/plupload/assets/js. Make sure that you already have jQuery loaded on your page.

Initialize Plupload

<script>
$(function () {
    createUploader('my_uploader_id'); // The Id that you used to create with the builder
});
</script>

These following methods are useable with the upload.js file.

Set Uploader options

setOptions(array $options)

Set uploader options. Please visit https://github.com/moxiecode/plupload/wiki/Options to see all the options. You can set the default global options in config/plupload.php

{!! plupload('my_uploader_id', route('photos.store'))
    ->setOptions([
        'filters' => [
            'max_file_size' => '2mb',
            'mime_types' => [
                ['title' => 'Image files', 'extensions' => 'jpg,gif,png'],
            ],
        ],
    ]) !!}

Automatically start upload when files added

Use setAutoStart() in your builder before calling render() function.

setAutoStart($bool)

  • $bool: true or false
{!! plupload('my_uploader_id', route('photos.store'))->setAutoStart(true) !!}

Receiving files

file($name, $handler)

  • $name: the input name.
  • $handler: callback handler.

Use this in your route or your controller. Feel free to modify to suit your needs.

return Plupload::file('file', function($file) {
    // Store the uploaded file using storage disk
    $path = Storage::disk('local')->putFile('photos', $file);

    // Save the record to the db
    $photo = App\Photo::create([
        'name' => $file->getClientOriginalName(),
        'type' => 'image',
        // ...
    ]);

    // This will be included in JSON response result
    return [
        'success' => true,
        'message' => 'Upload successful.',
        'id' => $photo->id,
        // 'url' => $photo->getImageUrl($filename, 'medium'),
        // 'deleteUrl' => route('photos.destroy', $photo)
        // ...
    ];
});

Helper is also available

return plupload()->file('file', function($file) {

});

If you are using the package upload.js file. The url and deleteUrl in the JSON payload will be used to generate preview and delete link while the id will be appended to the uploader as a hidden field with the following format:

<input type="hidden" name="{uploaderId}_files[]" value="{id}" />.

Please note that the deleteUrl uses DELETE method.

jenky/laravel-plupload 适用场景与选型建议

jenky/laravel-plupload 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 19.5k 次下载、GitHub Stars 达 29, 最近一次更新时间为 2015 年 04 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「plupload」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 jenky/laravel-plupload 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 jenky/laravel-plupload 我们能提供哪些服务?
定制开发 / 二次开发

基于 jenky/laravel-plupload 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 19.5k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 29
  • 点击次数: 15
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 29
  • Watchers: 2
  • Forks: 10
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-04-07