upload file

I am trying to upload a file with CActiveForm but when I write


print_r($_files);die();

there is an empty array.

what is wrong?


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

	'id'=>'ind-pdf-form',

	'enableAjaxValidation'=>false,

    'htmlOptions' =>array(type=>"multipart/form-data" )

)); ?>....

<?php echo $form->fileField($model,'title'); ?>

I solve that problem but now the file is not uploaded.

And also I have the error


Ind_pdfController does not have a method named "addError".

what is wrong?


$model=new ind_pdf;

...

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

            Yii::import('application.extensions.upload.Upload');

            //print_r($_FILES);die();

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

            $Upload = new Upload( (isset($_FILES['ind_pdf']['title']) ?$_FILES['ind_pdf']['title']  : null) );

            $destPath = Yii::app()->getBasePath().'/../pdf/';

            $Upload->process($destPath);

            if ($Upload->processed) {

                $model->title = $Upload->file_dst_name;

                if($model->save())

                    $this->redirect(array('view','id'=>$model->code));

            }

            else

                 $model->addError('title',$Upload->error);

[EDIT] I solved it .

Yeah, please, could you tell us how did you solve the problem ?




 $destPath = Yii::app()->getBasePath().'/../pdf/';




Problem was in destination path this is not alowed

I´ve solved the problem with the empty array by changing $_POST to $_FILES

Here is a tutorial.

I used it and I do a custom validation if needed, checking the $_FILES array because I had the "Image cannot be blank" problem as mentioned there.