Hello,
I am trying to upload a image by a form to my Model. I am using Yii 1.1
The model doesn’t contain in database the column “image”, so I have created the attribute in the model like this
public $image;
I have added in rules the following
array(‘image’, ‘file’, ‘types’=>‘jpg,gif,png’, ‘allowEmpty’=>true),
In the view I added to the form the htmlOption array(‘enctype’ => ‘multipart/form-data’), while for the file upload I did this:
<th><?php echo $form->labelEx($model, ‘image’); ?></th>
<td><?php echo $form->fileField($model, ‘image’);?></td>
<th><?php echo $form->error($model, ‘image’);’>’?></th>
I see the button for uploading the picture, when I press the button the action of my controller is called. I am showing in my controller a log with the $_POST and $_FILES, I receive all data related with my model, but I dont receive any data in $_FILES.
Log from the $_FILES
2016/07/07 18:18:12 [info] [application] FILE :
Array
(
)
Log that I receive from the $_POST
[MyModel] => Array
(
[Name] => My Name
[Description] => What ever
......
[image] =>
)
I have used Postman to call directly to the controller passing same data and image and in the log I can see in $_FILES the picture.
Any help?