Uploading Picture troubles


I’m a new to yii, so I was following this tutorial.

when I try to upload picture it reports empty field even if it is not.

my _form view:

[font="Courier New"]<div class="form">

<?php $form=$this->beginWidget(‘CActiveForm’, array(



'htmlOptions' =&gt; array('enctype' =&gt; 'multipart/form-data'),

)); ?>

&lt;div class=&quot;row&quot;&gt;

	&lt;?php echo &#036;form-&gt;labelEx(&#036;model,'path_to'); ?&gt;

	&lt;?php echo &#036;form-&gt;fileField(&#036;model,'path_to'); ?&gt;

	&lt;?php echo &#036;form-&gt;error(&#036;model,'path_to'); ?&gt;


<?php $this->endWidget(); ?>

</div><!-- form -->


and here is my action method:

[font="Courier New"] public function actionCreate()


	&#036;model=new Picture;







			&#036;log-&gt;lwrite('in save'.&#036;model-&gt;picture);










when I print_r($_FILES) everything what should be there is there

when I print_r($_POST) the field ‘path_to’ is empty and the validator probably is picking that one.

I’m probably missing something here and I’m clueless.


I’ve noticed yii is using hidden field with the same name as file input, than attributes are read from $_POST, which is causing the engine reading empty hidden field.

I understand that the hidden field is there for update when user is not entering new picture.

Can anyone advice what is the best way of doing picture upload?


I have an active discussion and bug report regarding this issue:


Yes, the hidden field is always empty (totally dumb). You will need to use your own hidden field, or correct the core framework file as I have done (read my posts).

You understand incorrectly that the hidden field is there for update when a new image is not uploaded. That is what we would expect, however its not possible for the hidden field to contain a value. I am still awaiting the dev team’s answer as to the purpose of the hidden field (I cannot see any).