2017 © Pedro Peláez
 

yii2-extension yii2-image-upload

upload image via ajax

image

troy/yii2-image-upload

upload image via ajax

  • Saturday, March 24, 2018
  • by troyFan
  • Repository
  • 3 Watchers
  • 9 Stars
  • 1,394 Installations
  • JavaScript
  • 0 Dependents
  • 0 Suggesters
  • 7 Forks
  • 1 Open issues
  • 2 Versions
  • 13 % Grown

The README.md

ajaxImageUpload

upload image via ajax, (*1)

Installation

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

Either run, (*3)

php composer.phar require --prefer-dist troy/yii2-image-upload ""

or add, (*4)

"troy/yii2-image-upload": ""

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

Usage

Once the extension is installed, simply use it in your code by :, (*6)

<a id="imageUpload" href="javascript:;">上传图片</a>
<?= \troy\ImageUpload\ImageUpload::widget(
    [
         'targetId' => 'imageUpload',//html dom id
         'config' =>[
             'action' =>Yii::$app->getUrlManager()->createUrl(['site/index'])
         ]
    ]
); ?>

You also can add some events for it such as onComplete function, (*7)


= ..... use yii\web\JsExpression; ..... \troy\ImageUpload\ImageUpload::widget( [ 'targetId' => 'imageUpload',//html dom id 'config' =>[ 'action' =>Yii::$app->getUrlManager()->createUrl(['site/index']), 'onComplete' => new JsExpression("function(fileName, responseJSON){ something todo...... }") ] ] ); ?>

if you want to the the UploadAction in this ext you can use :, (*8)


class SiteController extends Controller { public function actions() { return [ 'upload' => [ 'class' => 'troy\ImageUpload\UploadAction', 'successCallback' => [$this, 'successCallback'], 'beforeStoreCallback' => [$this,'beforeStoreCallback'] ], ] } public function successCallback($store,$file) { } public function beforeStoreCallback($file) { } }

The Versions

24/03 2018

dev-master

9999999-dev

upload image via ajax

  Sources   Download

BSD-3-Clause

The Requires

 

by Avatar troyFan

extension yii2 ajax image-upload

17/12 2014

1.0

1.0.0.0

upload image via ajax

  Sources   Download

BSD-3-Clause

The Requires

 

by Avatar troyFan

extension yii2 ajax image-upload