2017 © Pedro Peláez
 

yii2-module yii2-upload

Upload for yii2 app

image

myzero1/yii2-upload

Upload for yii2 app

  • Tuesday, November 21, 2017
  • by myzero1
  • Repository
  • 0 Watchers
  • 0 Stars
  • 59 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 5 % Grown

The README.md

yii2-upload

You can upload file,Just a add a widget to view., (*1)

Installation

The preferred way to install this module is through composer., (*2)

Either run, (*3)

php composer.phar require myzero1/yii2-upload:1.*

or add, (*4)

"myzero1/yii2-upload": "~1"

to the require section of your composer.json file., (*5)

Setting

Once the module is installed, simply modify your application configuration as follows:, (*6)

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

Usage

Add upload widget like following:, (*7)


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' => [] ]);

With ActiveForm, (*8)


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' => [] ] );

You can then access Upload testing through the following URL:, (*9)

http://localhost/path/to/index.php?r=upload/upload/test

or if you have enabled pretty URLs, you may use the following URL:, (*10)

http://localhost/path/to/index.php/upload/upload/test

The Versions

21/11 2017

dev-master

9999999-dev

Upload for yii2 app

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Xuanwu Qin

21/11 2017

1.0.5

1.0.5.0

Upload for yii2 app

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Xuanwu Qin

20/11 2017

dev-develop

dev-develop

Upload for yii2 app

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Xuanwu Qin

20/11 2017

1.0.4

1.0.4.0

Upload for yii2 app

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Xuanwu Qin

16/11 2017

1.0.3

1.0.3.0

Upload for yii2 app

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Xuanwu Qin

16/11 2017

1.0.2

1.0.2.0

Upload for yii2 app

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Xuanwu Qin

14/11 2017

1.0.1

1.0.1.0

Upload for yii2 app

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Xuanwu Qin

14/11 2017

1.0.0

1.0.0.0

Upload for yii2 app

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Xuanwu Qin