[Solved] Filefieldcontrolgroup Empty Post Variable

looks like it’s my day of running into walls…

I have the following lines in my view:




$form=$this->beginWidget('bootstrap.widgets.TbActiveForm', array(

	'id'=>'whats-new-form',

	// Please note: When you enable ajax validation, make sure the corresponding

	// controller action is handling ajax validation correctly.

	// There is a call to performAjaxValidation() commented in generated controller code.

	// See class documentation of CActiveForm for details on this.

	'enableAjaxValidation'=>false,

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


...


<?php echo $form->fileFieldControlGroup($model, 'filename'); ?>



in the model rules this:




	array('filename',

                    'file',

                    'allowEmpty' => true,

                    // 'types'=>'jpg, gif, png',

                    // 'maxSize'=>1024 * 1024 * 50, // 50MB

                    // 'tooLarge'=>'The file was larger than 50MB. Please upload a smaller file.',

            ),




and in the controller I do a print_r on the $_POST variables:




        public function actionCreate()

	{

		$model=new WhatsNew;


		// Uncomment the following line if AJAX validation is needed

		// $this->performAjaxValidation($model);


		if (isset($_POST['WhatsNew'])) {

			

			$model->attributes=$_POST['WhatsNew'];


			$model->filename = CUploadedFile::getInstance($model,'image');


			print_r($_POST);

			Yii::app()->end();		

		        ...



and while all other variables display the entered values, the ‘filename’ attribute is always blank

i have looked at a lot of similar topics, but none seem to work for me

Files are in the $_FILES array and you call CUploadedFile::getInstance on an ‘image’ attribute instead of ‘filename’.

Thanks for the slap in the face :wink: That works fine now