PHP code example of myzero1 / yii2-upload

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

    

myzero1 / yii2-upload example snippets


return [
    'modules' => [
        'upload' => [
            'class' => 'myzero1\yii2upload\Tools',
            'upload' => [
                'basePath' => '@webroot/upload',
                'baseUrl' => '@web/upload',
            ],
        ],
        // ...
    ],
    // ...
];

php composer.phar 


echo \myzero1\yii2upload\widget\upload\Upload::widget([
    'model' => $model,
    'attribute' => 'logo',
    // 'url' => ['/tools/upload/upload'], // default ['/tools/upload/upload'],
    // 'sortable' => true,
    // 'maxFileSize' => 200  * 1024, // 200k
    // 'minFileSize' => 1 * 1024, // 1k
    // 'maxNumberOfFiles' => 1, // default 1,
    // 'acceptFileTypesNew' => [], // default ['gif','jpeg','jpg','png'],
    // 'acceptFileTypes' => new \yii\web\JsExpression('/(\.|\/)(gif|jpe?g|png)$/i'),// if it is null,the acceptFileTypesNew will working.
    // 'showPreviewFilename' => false,
    // 'clientOptions' => []
]);




echo $form->field($model, 'logo')->widget(
    '\myzero1\yii2upload\widget\upload\Upload',
    [
        // 'url' => ['/tools/upload/upload'], // default ['/tools/upload/upload'],
        // 'sortable' => true,
        // 'maxFileSize' => 200  * 1024, // 200k
        // 'minFileSize' => 1 * 1024, // 1k
        // 'maxNumberOfFiles' => 1, // default 1,
        // 'acceptFileTypesNew' => [], // default ['gif','jpeg','jpg','png'],
        // 'acceptFileTypes' => new \yii\web\JsExpression('/(\.|\/)(gif|jpe?g|png)$/i'),// if it is null,the acceptFileTypesNew will working.
        // 'showPreviewFilename' => false,
        // 'clientOptions' => []
    ]
);