title: File upload (Yii)
body: <p>I'm implementing some file uploading fields and i'm having some difficulties with it.
  I was following this <a href="http://www.yiiframework.com/wiki/2/" rel="nofollow">article</a> and everything was perfect until I tried to update my model.
  If I didn't fill the file field, it was cleared after save. I was googling and find this <a href="http://www.yiiframework.com/forum/index.php/topic/5419-optional-upload-file-when-update-a-record/" rel="nofollow">topic</a>. I've modified my code, but now, when I try to modify another field, it isn't save, unless I modify the image field too. 
  Where's the problem? 
  My model code: </p>
  
  <pre><code>    public function actionUpdate($id)
      {
          $model=$this-&gt;loadModel($id);
  
          // Uncomment the following line if AJAX validation is needed
          // $this-&gt;performAjaxValidation($model);
  
          if(isset($_POST['Company']))
          {
              $model-&gt;attributes=$_POST['Company'];
              $the_image = CUploadedFile::getInstance($model,'image');
              if (is_object($the_image) &amp;&amp; get_class($the_image)==='CUploadedFile')
                $model-&gt;image = $the_image;
              if($model-&gt;save())
                  if (is_object($the_image))
                  $model-&gt;image-&gt;saveAs(Yii::getPathOfAlias('webroot') . '/upload/' . $model-&gt;image);
                  $this-&gt;redirect(array('view','id'=&gt;$model-&gt;id));
          }
  
          $this-&gt;render('update',array(
              'model'=&gt;$model,
      }
  </code></pre>
  
  <p>And these are the rules in my model:</p>
  
  <pre><code>            array('name', 'required'),
              array('type, number, rating, user_id', 'numerical', 'integerOnly'=&gt;true),
              array('name, image, address, site, mail', 'length', 'max'=&gt;1000),
              array('text', 'safe'),
              array('image', 'file', 'types'=&gt;'jpg, gif, png'),
              array('image', 'unsafe'),
              // The following rule is used by search().
              // Please remove those attributes that should not be searched.
              array('id, type, name, text, address, site, mail, number, rating, user_id', 'safe', 'on'=&gt;'search'),
  </code></pre>
  
  <p>Please, help me. I have no clue why it isn't working.</p>