定制 troy/yii2-image-upload 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

troy/yii2-image-upload

最新稳定版本:1.0

Composer 安装命令:

composer require troy/yii2-image-upload

包简介

upload image via ajax

README 文档

README

upload image via ajax

Installation

The preferred way to install this extension is through composer.

Either run

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

or add

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

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by :

<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

<?=
.....
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 :


 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)
      {
      }
  }

统计信息

  • 总下载量: 2.88k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 10
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 10
  • Watchers: 3
  • Forks: 4
  • 开发语言: JavaScript

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2014-04-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固