承接 hostkurd/flocms-uploader 相关项目开发

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

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

hostkurd/flocms-uploader

Composer 安装命令:

composer require hostkurd/flocms-uploader

包简介

Professional file and image upload package for FloCMS with local, private and S3-ready storage drivers.

README 文档

README

hostkurd/flocms-uploader is a production-ready upload package for FloCMS. It supports:

  • local public uploads
  • local private uploads
  • AWS S3 uploads
  • secure MIME and extension validation
  • random filenames by default
  • optional original-name preservation
  • date-based folders
  • single and multi-file uploads
  • image resizing, fitting, optimization, and version generation
  • GD or Imagick image drivers

Installation

composer require hostkurd/flocms-uploader

For AWS S3 support:

composer require aws/aws-sdk-php

Recommended FloCMS structure

  • public/uploads for publicly accessible assets like avatars, post images, and product photos.
  • storage/uploads for protected files like invoices, reports, and private user documents.

Configure the package

Create config/upload.php in your FloCMS app and copy the example from this package.

use FloCMS\Uploader\Uploader;

Uploader::configure(require ROOT . '/config/upload.php');

A good place to do that is inside your bootstrap sequence, right after your framework loads config.

Example config

return [
    'default_disk' => 'public',
    'disks' => [
        'public' => [
            'driver' => 'local',
            'root' => ROOT . '/public/uploads',
            'url' => '/uploads',
            'visibility' => 'public',
        ],
        'private' => [
            'driver' => 'local',
            'root' => ROOT . '/storage/uploads',
            'visibility' => 'private',
        ],
        's3' => [
            'driver' => 's3',
            'key' => getenv('AWS_ACCESS_KEY_ID') ?: '',
            'secret' => getenv('AWS_SECRET_ACCESS_KEY') ?: '',
            'region' => getenv('AWS_DEFAULT_REGION') ?: 'us-east-1',
            'bucket' => getenv('AWS_BUCKET') ?: '',
            'url' => getenv('AWS_URL') ?: null,
            'prefix' => 'uploads',
            'visibility' => 'public',
        ],
    ],
];

Basic file upload

use FloCMS\Uploader\Uploader;

Uploader::configure(require ROOT . '/config/upload.php');

$result = Uploader::disk('public')
    ->directory('documents')
    ->useDatePath()
    ->allowExtensions(['pdf', 'docx', 'jpg', 'jpeg', 'png'])
    ->maxBytes(10 * 1024 * 1024)
    ->upload($_FILES['attachment']);

$fileData = $result->toArray();

Directory selection

You can choose the target directory per upload:

Uploader::disk('public')->directory('avatars')->upload($_FILES['avatar']);
Uploader::disk('private')->directory('invoices')->upload($_FILES['invoice']);

Multiple uploads

$results = Uploader::disk('public')
    ->directory('gallery')
    ->uploadMany($_FILES['images']);

Image uploads with versions

$result = Uploader::image()
    ->onDisk('public')
    ->directory('posts')
    ->useDatePath()
    ->maxBytes(5 * 1024 * 1024)
    ->versions([
        'large' => ['resize' => [1600, 1600]],
        'medium' => ['resize' => [800, 800]],
        'thumb' => ['fit' => [300, 300], 'format' => 'webp', 'quality' => 82],
    ])
    ->upload($_FILES['image']);

$thumbUrl = $result->versionUrl('thumb');

The original image is kept by default and stored under:

posts/2026/03/original/abc123.jpg

Generated versions are stored like:

posts/2026/03/large/abc123.jpg
posts/2026/03/medium/abc123.jpg
posts/2026/03/thumb/abc123.webp

AWS S3 example

$result = Uploader::disk('s3')
    ->directory('products')
    ->useDatePath()
    ->allowExtensions(['jpg', 'jpeg', 'png', 'webp'])
    ->upload($_FILES['image']);

Security notes

  • The package validates upload errors before moving files.
  • It uses finfo to detect MIME type.
  • It validates file extension and MIME type independently.
  • It uses random filenames by default.
  • It validates real images with getimagesize() before image processing.
  • It does not support SVG sanitization. Do not allow SVG uploads until you add a sanitizer.

Public API overview

FloCMS\Uploader\Uploader

  • configure(array $config): void
  • disk(string $disk): Uploader
  • make(?array $config = null): Uploader
  • onDisk(string $disk): self
  • directory(string $directory): self
  • to(string $directory): self
  • useDatePath(bool $enabled = true): self
  • preserveOriginalName(bool $enabled = true): self
  • filename(string $filename): self
  • visibility(string $visibility): self
  • allowExtensions(array $extensions): self
  • allowMimeTypes(array $mimes): self
  • maxBytes(int $bytes): self
  • imageDimensions(array $dimensions): self
  • upload(array $file, ?string $directory = null): UploadResult
  • uploadMany(array $files, ?string $directory = null): array

FloCMS\Uploader\Image\ImageUploader

  • versions(array $versions): self
  • keepOriginal(bool $enabled = true): self
  • optimize(bool $enabled = true): self
  • quality(int $quality): self
  • driver(string $driver): self

FloCMS integration suggestion

Inside your bootstrap after config is loaded:

use FloCMS\Uploader\Uploader;

if (is_file(ROOT . '/config/upload.php')) {
    Uploader::configure(require ROOT . '/config/upload.php');
}

Then your controllers can use the package directly.

Notes

  • Uploader::disk('public') is the clean entry point for regular files.
  • Uploader::image()->onDisk('public') is the clean entry point for image processing.
  • If you want a framework-level helper later, you can wrap this package with your own upload() or uploader() helper in FloCMS core.

hostkurd/flocms-uploader 适用场景与选型建议

hostkurd/flocms-uploader 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 16 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 hostkurd/flocms-uploader 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 17
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 33
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-16