Krajee Bootstrap File Input, catching AJAX success response

前端 未结 5 2066
无人共我
无人共我 2021-02-08 04:21

I\'m using Krajee the Bootstrap File Input plugin to perform an upload via AJAX call.

Here is the link to the Krajee plugin AJAX section: Krajee plugin AJAX

The

5条回答
  •  囚心锁ツ
    2021-02-08 04:26

    field($model, 'icon_path')->widget(FileInput::classname(), [
            'options'           =>  ['accept' => 'image/*','multiple'=>false, 'id' => 'category_icon_image'],
            'pluginLoading'     =>  false,
            'pluginOptions'     =>  [
            'initialPreview'        =>  (!$model->isNewRecord) ? [
                'web/filebox/'.$model->icon_path
            ] : '',
                'initialPreviewAsData'  =>  true,
                'browseIcon'            =>  ' ',
                'showPreview'           =>  true,
                'showCaption'           =>  false,
                'showRemove'            =>  false,
                'showUpload'            =>  false,
                'showClose'             =>  false,
                'previewTemplates'      =>  'object',
                'layoutTemplates'       =>  'preview',
                'uploadUrl'             =>  'category-item/category-item/ajax-image-upload',
                'uploadAsync'           =>  false,
                'deleteUrl'             =>  Url::toRoute('category-item/delete-image?id='.$model->category_item_id)
            ],
            'pluginEvents'  =>  [
                'filebatchuploadsuccess' => 'function(event, data, previewId, index) {
                    console.log(data.response)
                }',
                'filebatchselected' => "function(event,files){
                    var input = $('#category_icon_image');
                    input.fileinput('upload');
                    $('#categoryitem-icon_path_pre').val(files[0].name);
                }",
            ],
        ])
    ?>
    

提交回复
热议问题