albert221 / laravel-filepond
具有更多功能的 FilePond 上传处理器。
v1.0.2
2020-07-05 19:28 UTC
Requires
- php: ^7.4
- laravel/framework: ^7.0
Requires (Dev)
- phpunit/phpunit: ^9.1
This package is auto-updated.
Last update: 2024-09-07 04:10:07 UTC
README
此包提供基本的 FilePond Laravel 功能,并有助于处理禁用 JS 发送的文件。
此包是在匆忙中编写的。可能没有很好地文档化或测试,但应该可以工作。欢迎提交修复此问题的拉取请求。
安装
composer require albert221/laravel-filepond
如果您需要更改配置
php artisan vendor:publish --provider="Albert221\Filepond\FilepondServiceProvider"
用法
前端
FilePond.setOptions({ server: '/filepond' });
后端
// app/Http/Controllers/SomeController.php public function someAction(Request $request, Filepond $filepond) { // Thanks to `fromRequest` method, it works both when JS was on and off. /** @var UploadedFile|[]UploadedFile $file */ $file = $filepond->fromRequest($request, 'file'); // (...) }
验证
// app/Http/Requests/SomeRequest.php public function rules(FilepondSerializer $filepondSerializer): array { return [ 'foobar' => 'required', 'file' => [ 'required', // It validates both UploadedFile and FilePond's serverId new FilepondRule($filepondSerializer, [ 'mimetypes:audio/mpeg' ]), ], ]; }
许可证
本项目深受 Sopamo/laravel-filepond 的启发。
本项目采用 Apache 2.0 许可证。