Easily upload any files to your server in Yii Framework 2.0. The extension uses the jQueryFileUpload.
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist mztest/yii2-widget-file-upload "*"
or add
"mztest/yii2-widget-file-upload": "*"
to the require section of your composer.json
file.
-
Set upload action at your controller
public function actions() { return [ 'upload' => [ 'class' => 'mztest\upload\actions\FileUploadAction', ], ]; }
-
simply use it in your code by :
use mztest\upload\FileUpload; <?= $form->field($model, 'floor_image')->widget(FileUpload::className(), [ 'uploadAction' => ['upload'] ]) ?>