PHP code example of namest / drive

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

    

namest / drive example snippets


return [
    ...
    'providers' => [
        ...
        'Namest\Drive\DriveServiceProvider',
    ],
    ...
];

$file = Drive::accept($input_name);

// Set up validation rules in config file use laravel validation rules
return [
    ...
    'rules' => [
        'max:2048', // Kilobytes
        // Whatever you want
    ],
    ...
];

$nomal = $file->save();
$large = $file->save('-large'); // With file name suffix

// Recipe: $file-><intervention/image method>($parameters)
$small = $file->crop($width, $height, $x, $y)
              ->blur($percent)
              ->save('-small');

$avatar = $file->profile('avatar')->save();

// For example: apply `avatar` profile with every uploaded images.
// Edit in `drive` config
return [
    ...
    'default_profiles' => [
        'image' => ['avatar'],
        'video' => [],
    ],
    ...
];
bash
php artisan vendor:publish --provider="Namest\Drive\DriveServiceProvider"