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:
<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 but if I make a log for showing the $_POST and/or $_FILES i got this:
Log from the $_FILES
2016/07/07 18:18:12 [info] [application] FILE :
Array
(
)
Log that I receive from the $_POST
[Puntointeres] => Array
(
[Name] => My Name
[Description] => What ever
......
[image] =>
)
Any help?
enctypeattribute is actually set? given that yourimageinput shows up in $_POST, either you're not building the form correctly, or something's mangling it.