PHP code example of mhshagor / file-picker

1. Go to this page and download the library: Download mhshagor/file-picker 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/ */

    

mhshagor / file-picker example snippets


public function store(Request $request)
{
    $request->validate([
        'avatar' => '$request->hasFile('avatar')) {
        $file = $request->file('avatar');
        $path = $file->store('avatars', 'public');
        // Save path to database
    }

    if ($request->hasFile('gallery_images')) {
        foreach ($request->file('gallery_images') as $file) {
            $path = $file->store('gallery', 'public');
            // Save path to database
        }
    }
}
bash
php artisan vendor:publish --tag=file-picker
blade
<x-file-picker
    name="profile_image"
    label="Profile Image"
    preview-type="profile"
/>
blade
preview-type="file"
blade
@error('avatar')
    <p class="text-red-500 text-xs mt-1">{{ $message }}</p>
@enderror