kriss / yii2-web-uploader
webuploader for Yii2 http://fex.baidu.com/webuploader/
Installs: 91
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 1
Open Issues: 0
Type:yii2-extension
Requires
- npm-asset/webuploader: ^0.1.8
- yiisoft/yii2: ~2.0.0
README
webuploader for Yii2 http://fex.baidu.com/webuploader/
ScreenShot
Installation
composer require kriss/yii2-web-uploader
Usage
widgets
<?php use \kriss\webUploader\widgets\QuickWebUploader; echo QuickWebUploader::widget([ 'fileNumLimit' => 5, ]); // or echo $form->field($model, 'file')->widget(QuickWebUploader::class, [ 'uploadUrl' => ['/file/upload'], ]); ?>
actions
<?php namespace admin\controllers; use yii\web\Controller; use kriss\webUploader\actions\QuickDeleteAction; use kriss\webUploader\actions\QuickUploadAction; class FileController extends Controller { public function actions() { return [ 'upload' => [ 'class' => QuickUploadAction::class, 'savePath' => '@webroot/uploads', 'displayPath' => '@web/uploads', ], 'delete' => [ 'class' => QuickDeleteAction::class, 'savePath' => '@webroot/uploads', 'displayPath' => '@web/uploads', ], ]; } }
examples
only accept images
<?php // for client validate // QuickWebUploader [ 'pluginOptions' => [ 'accept' => [ 'extensions' => 'png,jpeg,jpg,gif', 'mimeTypes' => 'image/*', ], ], ]; // for server validate // QuickUploadAction [ 'validationRules' => [ ['file', 'file', 'extensions' => ['png', 'jpeg', 'jpg', 'gif'], 'mimeTypes' => 'image/*', 'maxSize' => 5*1024*1024] ], ];