dev-master
9999999-devupload image via ajax
BSD-3-Clause
The Requires
by troyFan
extension yii2 ajax image-upload
1.0
1.0.0.0upload image via ajax
BSD-3-Clause
The Requires
by troyFan
extension yii2 ajax image-upload
upload image via ajax
upload image via ajax, (*1)
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)
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) { } }
upload image via ajax
BSD-3-Clause
extension yii2 ajax image-upload
upload image via ajax
BSD-3-Clause
extension yii2 ajax image-upload