PHP code example of teknikhub / laravel-file-manager

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

    

teknikhub / laravel-file-manager example snippets


return [
    // The default disk to load when the file manager opens
    'default_disk' => env('TEKNIKHUB_FM_DISK', 'public'),

    // An array of disks the file manager is allowed to access and switch between
    'disks' => [
        'public',
        // 's3',
    ],

    // Restrict access to a specific subfolder within a disk (leave empty for root access)
    'root' => env('TEKNIKHUB_FM_ROOT', ''),

    // The URL path for the standalone file manager page
    'route_prefix' => env('TEKNIKHUB_FM_ROUTE_PREFIX', 'admin/file-manager'),

    // Middleware to protect the standalone routes (IMPORTANT: secure this!)
    'middleware' => ['web', 'auth'],

    // Upload constraints
    'upload' => [
        'max_size' => env('TEKNIKHUB_FM_MAX_SIZE', 10240), // Max size in KB (10MB)
        'multiple' => true, // Allow selecting multiple files at once
        'allowed_extensions' => [], // Whitelist: leave empty to allow all (except blocked)
        'blocked_extensions' => ['php', 'sh', 'exe', 'bat'], // Blacklist: malicious files
    ],
    
    // Thumbnail generation settings
    'thumbnails' => [
        'enabled' => true,
        'mode' => 'auto', // Auto-detects Intervention Image v2 or v3
        'width' => 300,
        'height' => 200,
        'quality' => 80,
        'cache_directory' => '.teknikhub-file-manager/thumbnails', // Hidden cache folder
    ],

    // Toggle specific UI features on or off
    'features' => [
        'upload' => true,
        'folders' => true,
        'rename' => true,
        'delete' => true,
        'copy' => true,
        'download' => true,
        // ... see config file for all toggles
    ],
];
bash
php artisan vendor:publish --provider="TeknikHub\FileManager\FileManagerServiceProvider" --force
bash
php artisan storage:link
blade
<x-teknikhub-file-manager />