alsous/laravel-filepond
Composer 安装命令:
composer require alsous/laravel-filepond
包简介
Laravel 12 FilePond integration — Blade component for single/multiple file uploads with old() support
README 文档
README
Laravel 12 package for FilePond — Blade component that handles single/multiple uploads, image previews, old() restoration, and in-form deletion.
Installation
composer require alsous/laravel-filepond
php artisan vendor:publish --tag=filepond-config
How it works
- User selects files → FilePond uploads each file immediately to a temp endpoint → receives a UUID back.
- A hidden
<input>keeps the UUID(s) in the form. - User submits the form → your controller receives the UUID(s) → you call
Filepond::getFile($id)→ the file is ready to store permanently. - If validation fails,
old()restores the UUID(s) and FilePond re-displays the files — no re-upload needed. - Clicking X in FilePond removes the file and sends a DELETE to the temp endpoint.
Basic usage
Single file
<form method="POST" action="{{ route('profile.update') }}"> @csrf <x-filepond name="avatar" /> <button type="submit">Save</button> </form>
use Alsous\Filepond\Traits\InteractsWithFilepond; class ProfileController extends Controller { use InteractsWithFilepond; public function update(Request $request) { $request->validate([ 'avatar' => 'required|string', ]); $file = $this->filepondFile('avatar'); // FilepondFile|null $path = $file?->store('avatars'); // stored path auth()->user()->update(['avatar' => $path]); } }
Multiple files
<x-filepond name="photos" multiple max-files="10" />
$files = $this->filepondFiles('photos'); // FilepondFile[] foreach ($files as $file) { $path = $file->store('photos'); Photo::create(['path' => $path, 'user_id' => auth()->id()]); }
Component props
| Prop | Type | Default | Description |
|---|---|---|---|
name |
string |
— | Form field name |
multiple |
bool |
false |
Allow multiple files |
max-file-size |
string |
— | e.g. "5MB", "500KB" |
accepted-file-types |
array |
[] |
e.g. ['image/*'], ['application/pdf'] |
max-files |
int |
— | Max files in multiple mode |
image-preview |
bool |
true |
Show thumbnail previews for images |
include-assets |
bool |
true |
Auto-inject FilePond CSS/JS from CDN |
value |
string|array |
— | Pre-populate (UUID or array of UUIDs) |
label |
string |
— | Custom idle label (HTML allowed) |
disabled |
bool |
false |
Disable the pond |
required |
bool |
false |
Mark as required |
old() — automatic after validation failure
No extra code needed. The component reads old('fieldname') automatically.
public function store(Request $request) { $request->validate([ 'document' => 'required|string', 'title' => 'required|string|max:255', ]); // If validation fails here, the user is redirected back. // The component will restore the uploaded file automatically. }
<form method="POST" action="/documents"> @csrf <input name="title" value="{{ old('title') }}"> @error('title') <span>{{ $message }}</span> @enderror <x-filepond name="document" accepted-file-types='["application/pdf"]' /> @error('document') <span>{{ $message }}</span> @enderror <button type="submit">Upload</button> </form>
Pre-populate from a model (edit form)
Pass the stored UUID (or array) via :value.
{{-- Single --}} <x-filepond name="avatar" :value="$user->avatar_temp_id" /> {{-- Multiple --}} <x-filepond name="photos" multiple :value="$post->photo_temp_ids" />
Facade — use without the trait
use Alsous\Filepond\Facades\Filepond; // Single $file = Filepond::getFile($request->input('avatar')); $path = $file?->store('avatars'); // Multiple $files = Filepond::input($request->input('photos')); foreach ($files as $file) { $file->store('photos'); }
FilepondFile API
| Method | Returns | Description |
|---|---|---|
store($path, $disk) |
string |
Store using Laravel convention |
storeAs($path, $name, $disk) |
string |
Store with custom filename |
toUploadedFile() |
UploadedFile |
Convert to standard Laravel upload |
getFilePath() |
string |
Absolute filesystem path |
$file->originalName |
string |
Original filename |
$file->mimeType |
string |
MIME type |
$file->size |
int |
Size in bytes |
Loading your own assets
Set :include-assets="false" and load FilePond in your layout <head>:
<link rel="stylesheet" href="https://unpkg.com/filepond@^4/dist/filepond.min.css"> <link rel="stylesheet" href="https://unpkg.com/filepond-plugin-image-preview/dist/filepond-plugin-image-preview.min.css"> <script src="https://unpkg.com/filepond@^4/dist/filepond.min.js"></script> <script src="https://unpkg.com/filepond-plugin-image-preview/dist/filepond-plugin-image-preview.min.js"></script> <script src="https://unpkg.com/filepond-plugin-file-validate-type/dist/filepond-plugin-file-validate-type.min.js"></script> <script src="https://unpkg.com/filepond-plugin-file-validate-size/dist/filepond-plugin-file-validate-size.min.js"></script>
<x-filepond name="avatar" :include-assets="false" />
Configuration (config/filepond.php)
'temp_disk' => 'local', // Storage disk for temp files 'temp_folder' => 'filepond/temp', // Folder inside the disk 'route_prefix' => 'filepond', // URL prefix: /filepond/process 'middleware' => ['web'], // Middleware on FilePond routes 'max_upload_size' => 102400, // KB — 100 MB default
Add auth to middleware to require authentication on uploads:
'middleware' => ['web', 'auth'],
Artisan commands
# Publish config php artisan vendor:publish --tag=filepond-config # Publish views (to customise the component template) php artisan vendor:publish --tag=filepond-views
Requirements
- PHP 8.2+
- Laravel 12
alsous/laravel-filepond 适用场景与选型建议
alsous/laravel-filepond 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 05 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「file-upload」 「filepond」 「blade-component」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 alsous/laravel-filepond 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 alsous/laravel-filepond 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 alsous/laravel-filepond 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Use FilePond fields in SilverStripe
Integrates the rekalogika/file library into the Symfony framework.
Upload files using Symfony Form, FilePond, and the rekalogika/file framework
A powerful chunked file upload field for Filament using Uppy.js with S3, remote sources (Google Drive, OneDrive, Dropbox), webcam, screen capture, audio recording, image editing and more.
Symfony bundle for automatic file upload handling on Doctrine ORM entities with S3, CDN, and multiple storage support
Arikaim CMS Filepond UI library
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 45
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-10