xakki/file-uploader-laravel
Composer 安装命令:
composer require xakki/file-uploader-laravel
包简介
Chunked file uploader package for Laravel 10-12 (Upload Protocol v1).
README 文档
README
Chunked file uploader for Laravel 10–12 speaking
Upload Protocol v1,
with a Drag & Drop JS widget. Thin binding over the framework-agnostic
xakki/file-uploader core.
Upgrading from 0.2? See MIGRATION.md. The public Laravel API (facades, routes, config, widget) is preserved; only the internals moved to the core.
composer require xakki/file-uploader-laravel
The service provider is auto-discovered. It registers the routes and, on package:discover,
publishes the config (without overwriting your edits) and the widget asset automatically.
New config keys from package upgrades are merged in at runtime, so an older published
config/file-uploader.php keeps working. To (re)publish manually:
php artisan vendor:publish --tag=file-uploader-config php artisan vendor:publish --tag=file-uploader-assets
Configure
config/file-uploader.php (key options):
'disk' => env('FILE_UPLOADER_DISK', 'public'), // any league/flysystem disk 'directory' => '/', 'chunk_size' => 1024 * 1024, // 1 MiB 'max_size' => 1024 * 1024 * 50, // 50 MiB 'max_files' => 0, // cap on active (non-deleted) files; 0 = unlimited (FILE_UPLOADER_MAX_FILES) 'allowed_extensions' => [ /* mime => ext map; '*' = any */ ], 'middleware' => ['web', 'auth'], 'route_prefix' => 'file-upload', 'soft_delete' => true, 'trash_ttl_days' => 30, 'public_url_resolver' => null, // fn(string $path, $disk): ?string 'full_access' => ['users' => [], 'roles' => []], // who may manage any file
S3 / CloudFront
Point disk at an s3 filesystem. For signed/CDN URLs, set public_url_resolver to a closure
returning the URL for a path (the core never calls $disk->url() itself).
Widget
Inject the widget service and render it in a Blade view:
public function show(\Xakki\LaravelFileUploader\Services\FileWidget $widget) { return view('page', ['uploader' => $widget->getWidget()]); }
{!! $uploader !!}
It emits the mount point, the JS config (route URLs + CSRF token + flags, including maxFiles) and
the published UMD widget from public/vendor/file-uploader/file-uploader.umd.js.
The 0.3.2 widget (from @xakki/file-uploader)
supports theming (light / dark / auto colour schemes, custom styles) and i18n (built-in
en / ru, plus per-string overrides). See the js README
for the full widget config surface.
HTTP API
Registered under route_prefix with the configured middleware:
| Method & path | Action |
|---|---|
POST {prefix}/chunks |
upload a chunk |
GET {prefix}/files |
list files |
DELETE {prefix}/files/{id} |
delete (soft by default) |
POST {prefix}/files/{id}/restore |
restore from trash |
DELETE {prefix}/trash/cleanup |
purge expired trash |
Responses use the shared Upload Protocol v1 envelope, identical to the Symfony binding and the demo.
PHP service
$widget = app(\Xakki\LaravelFileUploader\Services\FileWidget::class); $files = $widget->list(); $widget->delete($id); $widget->restore($id); $widget->cleanupTrash();
Services\FileUpload (uploads) and Services\FileWidget (management + widget) are thin subclasses of
the core FileUploader / FileManager, wired to Laravel's disk, Auth, Date and logger.
Console
php artisan file-uploader:cleanup # purge expired trash php artisan file-uploader:sync-metadata # rebuild metadata from stored files
i18n
Server messages (upload/chunk/trash/cleanup results, plus the error.* and
validation.* codes) are localized from the shared core catalog that ships inside
xakki/file-uploader (protocol/i18n/<locale>.json, 8 locales: en ru es pt zh fr de sr)
— the same catalog every binding and the JS client use. The response envelope now also
carries the stable code (and params) that produced the message, so clients can
re-localize.
The locale for these messages is resolved per Upload Protocol §5.1: the request locale
field (only when it is in the locales allow-list) → the locale config default → en.
Note: this supersedes the previous app()->getLocale() behaviour for these
server-produced messages — the protocol's per-request locale field now drives the
language.
The Laravel UploadChunkRequest (FormRequest) emits its per-field validation messages
through Laravel's own localization (the standard validation.* lines); only the upload/file
result text and the error.* / code envelope route through the shared core catalog.
Test
composer install && composer phpunit
Related
- Core (framework-agnostic):
Xakki/file-uploader· Packagistxakki/file-uploader - Sibling Symfony binding:
Xakki/file-uploader-symfony· Packagistxakki/symfony-file-uploader - Wire contract: Upload Protocol v1 — SPEC.md
- JS client / widget:
@xakki/file-uploader
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2026-06-15