kartik-v / yii2-widget-fileinput

An enhanced FileInput widget for Bootstrap 4.x/3.x with file preview, multiple selection, and more features (sub repo split from yii2-widgets)
Other
229 stars 96 forks source link

%252F in delete url #148

Closed palexandrite closed 5 years ago

palexandrite commented 5 years ago

Prerequisites

Steps to reproduce the issue

  1. Set up this plugin by Composer
  2. Implement it in code: $object[]['key'] = $company->id; echo $form->field($model, 'file')->widget(FileInput::class, [ 'options' => ['accept' => 'image/*'], 'pluginOptions' => [ 'deleteUrl' => Url::to(['/companies/delete-logo']), 'initialPreviewConfig' => $object,// конфигурация для удаления фотографий, 'initialPreview' => $company->logo ? Yii::$app->request->pathInfo.$company->logo : '', 'initialPreviewAsData' => true, 'fileActionSettings' => [ // 'initialPreviewShowDelete' => false, 'showZoom' => false, 'showRemove' => false, ], 'showCaption' => false, 'showRemove' => false, 'showUpload' => false, 'browseClass' => 'btn btn-primary btn-block', 'browseIcon' => '<i class="fas fa-camera-retro"></i>', 'browseLabel' => Yii::t('ih', 'Выбрать логотип'), 'maxFileSize' => 15000, ], ])
  3. Try to press on the delete button on the image and open a browser console. You will see an url with not a normal encoded slash like %2F but you will see this %252F.

Expected behavior and actual behavior

When I follow those steps, I see 404 error and not a normally encoded slash — %252F.

I was expecting to delete the image and a normally encoded slash — %2F.

Environment

Browsers

Operating System

Libraries

Isolating the problem

kartik-v commented 5 years ago

Update to the latest release of the extension via composer

kartik-v commented 5 years ago

If you are still facing the error try setting the encodeUrl property to false within pluginOptions.

palexandrite commented 5 years ago

If you are still facing the error try setting the encodeUrl property to false within pluginOptions.

Thank you very much, Kartik. I didn't get that error again. Thanks a lot.