yii2-crop-image-upload icon indicating copy to clipboard operation
yii2-crop-image-upload copied to clipboard

Not save images ?

Open kentuck13 opened this issue 9 years ago • 0 comments

i have not save images . I want save images for user : View :

'form-user', 'options' => ['enctype' => 'multipart/form-data']]); ?>
        <li><?php echo $form->field($model, 'username'); ?></li>
        <li><?php echo $form->field($model, 'email'); ?></li>
        <li><?php echo $form->field($model, 'name_fml'); ?></li>
        <?= $form->field($model, 'photo')->widget(CropImageUpload::className()) ?>
        <button class="btn btn-success">Save<button>
        <br><br>
        <?php ActiveForm::end(); ?>

User model : public $photo; public $photo_crop; public $photo_cropped; public function rules() { return [ ['status', 'default', 'value' => self::STATUS_ACTIVE], ['status', 'in', 'range' => [self::STATUS_ACTIVE, self::STATUS_DELETED]],

        [['currentPassword', 'newPassword', 'newPasswordConfirm'], 'requPas'],
        [['currentPassword'], 'validateCurrentPassword'],

        [['photo_crop', 'photo_cropped'], 'string', 'max' => 100],
        ['photo', 'file', 'extensions' => 'jpeg, gif, png, jpg', 'on' => ['insert', 'update']],

        [['newPassword', 'newPasswordConfirm'], 'string', 'min' => 6],
        [['newPassword', 'newPasswordConfirm'], 'filter', 'filter' => 'trim'],
        [['newPasswordConfirm'], 'compare', 'compareAttribute' => 'newPassword', 'message' => 'Пароли не совпадают']
    ];
}

public function behaviors()
{
    return [
        [
            'class' => CropImageUploadBehavior::className(),
            'attribute' => 'photo',
            'scenarios' => ['insert', 'update'],
            'path' => '@backend/web/images/user/',
            'url' => '@backend/web/images/user/',
            'ratio' => 1,
            'crop_field' => 'photo_crop',
            'cropped_field' => 'photo_cropped',
        ],
        TimestampBehavior::className(),
    ];
}

/////////////////////////////////////////////////////////////////////////////////////// template advanced. Tell me what am I doing wrong?

kentuck13 avatar Oct 13 '15 10:10 kentuck13