How to make CActiveForm of enctype multipart/form-data

How to get my form posted to type of enctype multipart/form-data

My _form has

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

'id'=&gt;'miscellaneous-pages-form',


'enableAjaxValidation'=&gt;false,

)); ?>

inside htmlOptions add the enctype tag


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

	'id'=>'miscellaneous-pages-form',

	'enableAjaxValidation'=>false,

'htmlOptions'=>array('enctype'=>'multipart/form-data'),

)); ?>

Is this right?

look at the documentation, matbe it is stand alone array

You must know that every widget - if you want to set it params it is the second param in the form of array.

widget(‘className’, array params)

Thanks

I had the same problem.

CUploadedFile::getInstance($model, ‘filename’);

was always returning null and saveAs(); said I was trying to call it on a non-object.

Adding


'htmlOptions'=>array('enctype'=>'multipart/form-data'),

solved the problem.

Thank you.