PHP code example of slawap / yii2-uploadcare

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

    

slawap / yii2-uploadcare example snippets


'components' => [
    'uploadcare' => [
        'class' => 'uploadcare\yii2\Api',
        'publicKey' => 'your_public_key',
        'secretKey' => 'your_secret_key',
        'globalWidgetOptions' => [
            'UPLOADCARE_LOCALE' => 'ru',
        ]
    ]
]


use uploadcare\yii2\UploadCare;

echo $form->field($model, 'logo')->widget(
    UploadCare::className(),
    [
        'options' => [
            'data' => [
                'multiple' => true
            ]
        ],
        'validators' => [
            new \yii\web\JsExpression('function (fileInfo) {
              console.log("test1");
            }'),
            new \yii\web\JsExpression('function (fileInfo) {
              console.log("test2");
            }')
        ]
    ]
);

    public function behaviors()
    {
        return [
            'logo' => [
                'class' => FilesBehavior::class,
                'groupUUID' => false,
                'attributes' => ['logo']
            ]
        ];
    }

echo Image::img($uuid, $options); //draw img tag
echo Image::img($image, ['width' => '100'])->resize(200)->crop(100,100); //resize and crop image, then render img tag