Uploaded files getting reset while updating

I am trying to upload multiple files which is working perfectly. Whenever I am trying to update(CRUD) everything gets reset. I have tried with comment in

http://www.yiiframework.com/wiki/2/

Still I am unable to solve the problem. This is my code




if(isset($_POST['documents']))

		                  {

                                  //  $valid=true;

                                   foreach($doc as $i=>$pqr)

                                   {

                                    if(!empty($_POST['documents'][$i]))

                                    {

                                     $doc[$i]->attributes=$_POST['documents'][$i];

                  //$photosEvent[$i]->photoUrl = CUploadedFile::getInstance($photosEvent[$i], "photoUrl[$i]" );

                                     $doc[$i]->document = CUploadedFile::getInstance($doc[$i], "document[$i]" );

                                if ( (is_object($file_flyer) && get_class($file_flyer)==='CUploadedFile'))

                                $doc[$i]->document = $file_flyer;

                                

                                     $doc[$i]->doc_link_id = $abc->document;

                                     $doc[$i]->student_id = $_GET['id'];

                                    if($doc[$i]->save(false))

                                   {

                                     if (is_object($file_flyer))

                    $doc[$i]->document->saveAs(Yii::app()->basePath.'/images/'.$doc[$i]->document);

                                    }

                                   }



Any body please help me




// your update action

function actionUpdate(){

// some other code

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

     foreach($doc as $i=>$pqr){

         if(!empty($_POST['documents'][$i])){

              $old_file=$doc[$i]->document;

              $doc[$i]->attributes=$_POST['documents'][$i];

              $newFile=CUploadedFile::getInstance($doc[$i], "document[$i]" );

              $haveFile=false;

              if(is_object($newFile) && $newFile instanceof CUploadedFile && $old_file!==$newFile->getName())

                    $haveFile=true;

              if($doc[$i]->validate()){

                   if($haveFile)

                        $doc[$i]->document=$newFile;

              $doc[$i]->save();

         }

      }

}




                                   }



Can you give us some information.

Like the action?