Git Product home page Git Product logo

Comments (2)

CTOlet avatar CTOlet commented on July 29, 2024

Still cannot realize when and how does it happen.

from yii2-attachments.

m1roff avatar m1roff commented on July 29, 2024

Ive got same problem, and cant solve it((
after upload contorller returns only file name
I overload method actionUpload in FileController to return json data

{"initialPreviewConfig":[{"url":"/attachments/file/delete-temp?filename=pattern1.jpg","key":""}],"append":true}

but its not fixed problem.

Checked another project with native use of kartik\file\FileInput, everything works with json data above.

Some screenshots
Your module init:

<?= AttachmentsInput::widget([
                    'id'      => Html::getInputId($model, 'files'), // Optional
                    'model'   => $model,
                    'options' => [ // Options of the Kartik's FileInput widget
                        'multiple' => true, // If you want to allow multiple upload, default to false
                        'accept'   => 'image/*',
                    ],
                    'pluginOptions' => [ // Plugin options of the Kartik's FileInput widget
                        // 'maxFileCount'          => 0,
                        'initialPreviewAsData' => true,
                        'overwriteInitial'      => true,
                        'showClose'             => false,
                        'showCaption'           => false,
                        'showUpload'            => true,
                        'uploadAsync'           => true,
                        'browseLabel'           => '',
                        'removeLabel'           => '',
                        'browseIcon'            => '<i class="glyphicon glyphicon-folder-open"></i>',
                        'removeIcon'            => '<i class="glyphicon glyphicon-remove"></i>',
                        'removeTitle'           => 'Cancel or reset changes',
                        // 'elErrorContainer'      => '#appeal-images-errors',
                        // 'msgErrorClass'         => 'alert alert-block alert-danger',
                        'defaultPreviewContent' => '<img src="/upload_image.png" alt="Фото проблемы" style="width: 160px">',
                        'layoutTemplates'       => "{main2: '{preview} ' +  btnCust + ' {remove} {browse}'}",
                        'allowedFileExtensions' => ["jpg", "png", "gif", "jpeg", 'svg'],
                    ]
                ]) ?>

2016-06-02_02-28-21

2016-06-02_02-29-19

And working project

<?=$form->field($model::photosModel(), 'uploadPhotos', ['template'=>"{label}\n{hint}\n{error}\n{input}\n"])
                ->hint($_photosHint, ['class'=>'alert alert-warning'])
                ->label(false)
                ->widget(FileInput::className(), [
            'name' => 'uploadPhotos[]',
            'options' => [
                'multiple' => true,
                'accept'   => 'image/jpg, image/png',
            ],
            'pluginOptions' => [
                'initialPreview'       => $model->photosInitialPreview(),
                'uploadUrl'            => \yii\helpers\Url::to(['/items/upload']),
                'uploadAsync'          => true,
                'overwriteInitial'     => false,
                'initialPreviewConfig' => $model->photosInitialPreviewConfig(),
                'uploadExtraData'      => ['id_items'=>$model->primaryKey],
                'maxImageWidth'        => 1600,
                'maxImageHeight'       => 1600,
            ],
            'pluginEvents' => [
                'filepredelete' => "function(){ return !confirm('Точно хотите удалить?')}"
            ],
        ]);?>

2016-06-02_02-29-57
2016-06-02_02-30-43

from yii2-attachments.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.