定制 fsuuaas/laravel-plupload 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

fsuuaas/laravel-plupload

Composer 安装命令:

composer require fsuuaas/laravel-plupload

包简介

Plupload package for Laravel 12

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

Requirements

  • PHP 8.2 or higher
  • Laravel 12.0 or higher

Installation

Require this package with composer:

composer require fsuuaas/laravel-plupload

The package will automatically register its service provider and facade.

Publish the package configuration:

php artisan vendor:publish --tag=plupload

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.

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) {
    // Handle the file upload
});

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.

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

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 10
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-07-02