PHP code example of dmalta / laravel-filepond
1. Go to this page and download the library: Download dmalta/laravel-filepond library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dmalta / laravel-filepond example snippets
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use RahulHaque\Filepond\Facades\Filepond;
class UserAvatarController extends Controller
{
/**
* Update the avatar for the user.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function update(Request $request)
{
// For single file validation
Filepond::field($request->avatar)
->validate(['avatar' => ' "extension" => "png",
// "filename" => "avatar-1",
// "location" => "avatars/avatar-1.png",
// "url" => "http://localhost/storage/avatars/avatar-1.png",
// ];
$galleryName = 'gallery-' . auth()->id();
$fileInfos = Filepond::field($request->gallery)
->moveTo('galleries/' . $galleryName);
// dd($fileInfos);
// [
// [
// "id" => 1,
// "dirname" => "galleries",
// "basename" => "gallery-1-1.png",
// "extension" => "png",
// "filename" => "gallery-1-1",
// "location" => "galleries/gallery-1-1.png",
// "url" => "http://localhost/storage/galleries/gallery-1-1.png",
// ],
// [
// "id" => 2,
// "dirname" => "galleries",
// "basename" => "gallery-1-2.png",
// "extension" => "png",
// "filename" => "gallery-1-2",
// "location" => "galleries/gallery-1-2.png",
// "url" => "http://localhost/storage/galleries/gallery-1-2.png",
// ],
// [
// "id" => 3,
// "dirname" => "galleries",
// "basename" => "gallery-1-3.png",
// "extension" => "png",
// "filename" => "gallery-1-3",
// "location" => "galleries/gallery-1-3.png",
// "url" => "http://localhost/storage/galleries/gallery-1-3.png",
// ],
// ]
}
}
namespace App\Models;
use Illuminate\Foundation\Auth\User as Authenticatable;
use RahulHaque\Filepond\Traits\HasFilepond;
class User extends Authenticatable
{
use HasFilepond;
}
User::find(1)->fileponds;
bash
php artisan vendor:publish --provider="RahulHaque\Filepond\FilepondServiceProvider"
bash
php artisan migrate