yii2-attachments and async upload


I’m having troubles using yii2-attachments and async upload in real life scenario (because locally it works great).

When I upload the app to my remote server and I try submitting a form with an average file attached, say 5MB, the model is saved but the file is not attached.

I configured my upload this way (as per docs):



        'id' => 'file-input',

        'model' => $model,

        'options' => [

            'multiple' => true,


        'pluginOptions' => [

            'maxFileCount' => 10, 

            'initialPreview' => $model->isNewRecord ? [] : $model->getInitialPreview(),

            'initialPreviewConfig' => $model->isNewRecord ? [] : $model->getInitialPreviewConfig(),




    <div class="form-group">

    <?= Html::submitButton('Salva', [

        'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary', 

        'onclick' => "$('#file-input').fileinput('upload');"




But when I hit the "Salva" button the upload starts along with the form submit itself. The latter finishes in a matter of seconds, while the upload takes at least 30s, so it never finishes.

I was considering changing the ‘onclick’ to attach the fileinput’s filebatchuploadcomplete method, but it doesn’t include the form data so I don’t know how to submit the form after all…

Suggestions welcome! thanks

I must correct myself. the upload is NOT async, because by default yii2-attachments creates the widget with



Yet it’s ajax, so it’s probably async to the submitted form.