2017 © Pedro Peláez
 

yii2-extension yii2-widget-fileinput

yii2图片上传

image

bailangzhan/yii2-widget-fileinput

yii2图片上传

  • Monday, March 13, 2017
  • by bailangzhan
  • Repository
  • 0 Watchers
  • 2 Stars
  • 27 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

yii2-widget-fileinput

此扩展为解决 Yii2 framework 图片上传过程中不能预览的问题,目前只支持同步单图上传。, (*1)

安装

推荐使用composer进行安装, (*2)

$ php composer.phar require bailangzhan/yii2-widget-fileinput "@dev"

或者添加, (*3)

"bailangzhan/yii2-widget-fileinput": "@dev"

到你的composer.json文件的require中, (*4)

使用

视图文件, (*5)

<?= $form->field($model, 'imageColumn')->widget('bailangzhan\FileInput', [
    'clientOptions' => [
        // 'imageServer' => '',
    ],
]) ?>

控制器

控制器的代码需要自行实现,只需要在save之前为图片字段赋值即可,如, (*6)

($file = Upload::up($model, 'imageColumn')) && $model->imageColumn = $file;
$model->save();

注意

你需要在params.php中配置bailangzhan\FileInput::imageDomainConfigParam,或者在bailangzhan\FileInput::clientOptions中配置固定参数imageServer,该参数是图片服务器的域名,在修改model的时候正确的展示图片, (*7)

许可

yii2-widget-fileinput is released under the BSD 3-Clause License. See the bundled LICENSE.md for details., (*8)

The Versions

13/03 2017

dev-master

9999999-dev

yii2图片上传

  Sources   Download

The Requires

 

by manks

yii2 fileinput