2amigos / yii2-file-upload-widget

BlueImp File Upload Widget for Yii2
Other
251 stars 140 forks source link

Data does not saving #78

Open SerikK opened 8 years ago

SerikK commented 8 years ago

Hi. Extension is saving images, but it does not save to attributes of model. As I see there are two inputs are created: and . And when I catch it in controller it does not return me anything in images attribute. I have the following configuration:

FileUploadUI::widget([
        'model' => $model,
        'attribute' => 'image',
        'url' => ['projects/imageupload', 'id' => $model->id],
        'gallery' => false,
        'fieldOptions' => [
                'accept' => 'image/*'
        ],
        'clientOptions' => [
                'maxFileSize' => 2000000
        ],
        'clientEvents' => [
                'fileuploaddone' => 'function(e, data) {
                                    }',
                'fileuploadfail' => 'function(e, data) {
                                    }',
        ],
    ]);

Can you explain how I can solve this?

tonydspaniard commented 8 years ago

@SerikK please, show your $image attribute rules and the action handling the upload

We have to do a bit of extra work here. The extension allows you to submit images, so the way to handle submissions is by using UploadedFile and then we need to set the attribute of our model programmatically to the source of the image. Is that what you do? Can you show me your code for uploading?

tonydspaniard commented 8 years ago

check latest additions to the master to find out whether you were doing something wrong or not: https://github.com/2amigos/yii2-file-upload-widget/tree/master/src/actions