yii2-file-upload-widget
yii2-file-upload-widget copied to clipboard
Data does not saving
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?
@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?
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